Conditions | 4 |
Paths | 4 |
Total Lines | 28 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4.128 |
Changes | 0 |
1 | <?php |
||
17 | 6 | public static function init(string $basePath) |
|
18 | { |
||
19 | 6 | $basePath = rtrim($basePath, '/'); |
|
20 | 6 | self::$env = new Dotenv($basePath); |
|
21 | |||
22 | try { |
||
23 | 6 | self::$env->load(); |
|
24 | } catch (InvalidPathException $e) { |
||
25 | throw InvalidConfiguration::dotEnvNotFound($basePath); |
||
26 | } |
||
27 | |||
28 | 6 | $configFiles = Finder::create()->files()->in($basePath . '/config')->name('*.php'); |
|
29 | |||
30 | 6 | $unparsedConfig = []; |
|
31 | |||
32 | /** @var SplFileInfo $configFile */ |
||
33 | 6 | foreach ($configFiles as $configFile) { |
|
34 | 6 | $fileConfig = require $configFile; |
|
35 | |||
36 | 6 | if (!is_array($fileConfig)) { |
|
37 | continue; |
||
38 | } |
||
39 | |||
40 | 6 | $unparsedConfig = array_merge($unparsedConfig, $fileConfig); |
|
41 | } |
||
42 | |||
43 | 6 | self::$loadedConfig = Arr::dot($unparsedConfig); |
|
44 | 6 | } |
|
45 | |||
56 |