Skip to content

Commit 133f044

Browse files
committed
[TASK] Remove background load() from get() method ofr Env class.
1 parent 566d69a commit 133f044

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

deployer/config/set.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
namespace Deployer;
44

5+
use RuntimeException;
56
use SourceBroker\DeployerInstance\Env;
67

78
set('default_stage', function () {
8-
$instance = (new Env())->get('INSTANCE');
9+
$env = new Env();
10+
$env->load();
11+
$instance = $env->get('INSTANCE');
912
if ($instance === null) {
10-
throw new \RuntimeException(
13+
throw new RuntimeException(
1114
'INSTANCE var is no set.',
1215
1602784218
1316
);

src/Env.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace SourceBroker\DeployerInstance;
44

5+
use RuntimeException;
56
use Symfony\Component\Dotenv\Dotenv;
67

78
class Env
@@ -25,7 +26,7 @@ public function load(string $configFile = null, $envKey = null): void
2526
}
2627
self::$envLoaded = true;
2728
} else {
28-
throw new \RuntimeException('Missing config file. Searching in: '
29+
throw new RuntimeException('Missing config file. Searching in: '
2930
. "\n" . $configFile, 1500717945887);
3031
}
3132
}
@@ -34,13 +35,9 @@ public function load(string $configFile = null, $envKey = null): void
3435
/**
3536
* @param string $envName
3637
* @return mixed|null
37-
* @throws \Exception
3838
*/
3939
public function get(string $envName)
4040
{
41-
if (!self::$envLoaded) {
42-
$this->load();
43-
}
4441
return $_ENV[$envName] ?? null;
4542
}
4643
}

0 commit comments

Comments
 (0)