Skip to content

Commit c968fe4

Browse files
added a Manager::class static public method - startEnvIFNotStarted()
1 parent 07305e4 commit c968fe4

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

Capsule/Manager.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@ private static function generate($length = 32)
9898
return $appKey;
9999
}
100100

101+
/**
102+
* Ensures that the environment is started if it has not been initialized yet.
103+
*
104+
* This method checks the current state of the environment and performs
105+
* initialization steps if necessary to guarantee that the environment is ready
106+
* for further operations.
107+
*
108+
* @return void
109+
*/
110+
public static function startEnvIFNotStarted()
111+
{
112+
// if ENV has not been started
113+
if(!Env::isEnvStarted()){
114+
Env::createOrIgnore();
115+
Env::load();
116+
}
117+
}
118+
101119
/**
102120
* Re-generate a new app KEY
103121
*

Mail.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Tamedevelopers\Support\Str;
66
use PHPMailer\PHPMailer\PHPMailer;
77
use Tamedevelopers\Support\Capsule\File;
8+
use Tamedevelopers\Support\Capsule\Manager;
89
use Tamedevelopers\Support\Traits\MailTrait;
910

1011
class Mail{
@@ -21,7 +22,7 @@ public function __construct($emails = null, ?array $options = [])
2122
{
2223
$this->mailer = new PHPMailer(true);
2324

24-
$this->startEnvIFNotStarted();
25+
Manager::startEnvIFNotStarted();
2526

2627
if(!empty($emails)){
2728
$this->recipients['to'] = $this->convert($emails, 'email');

Traits/MailTrait.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -370,24 +370,6 @@ private function setupMailer(?array $options = [])
370370
}
371371
}
372372

373-
/**
374-
* Ensures that the environment is started if it has not been initialized yet.
375-
*
376-
* This method checks the current state of the environment and performs
377-
* initialization steps if necessary to guarantee that the environment is ready
378-
* for further operations.
379-
*
380-
* @return void
381-
*/
382-
private function startEnvIFNotStarted()
383-
{
384-
// if ENV has not been started
385-
if(!Env::isEnvStarted()){
386-
Env::createOrIgnore();
387-
Env::load();
388-
}
389-
}
390-
391373
/**
392374
* isSMTP
393375
*

0 commit comments

Comments
 (0)