Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4.0119 |
Changes | 0 |
1 | <?php |
||
23 | 2 | public function loadEnvVariables(DirectoriesInterface $dirs, EnvironmentInterface $env): void |
|
24 | { |
||
25 | 2 | if ($this->init) { |
|
26 | return; |
||
27 | } |
||
28 | |||
29 | 2 | $this->init = true; |
|
30 | |||
31 | 2 | $dotenvPath = $env->get('DOTENV_PATH', $dirs->get('root') . '.env'); |
|
32 | |||
33 | 2 | if (!\file_exists($dotenvPath)) { |
|
34 | 1 | return; |
|
35 | } |
||
36 | |||
37 | 1 | $path = \dirname($dotenvPath); |
|
38 | 1 | $file = \basename($dotenvPath); |
|
39 | |||
40 | 1 | foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value) { |
|
41 | 1 | $env->set($key, $value); |
|
42 | } |
||
45 |