1 | <?php |
||
13 | class Config |
||
14 | { |
||
15 | protected static $env; |
||
16 | protected static $loadedConfig = []; |
||
17 | |||
18 | 6 | public static function init() |
|
19 | { |
||
20 | 6 | self::$env = new Dotenv(File::path()); |
|
21 | |||
22 | try { |
||
23 | 6 | self::$env->load(); |
|
24 | } catch (InvalidPathException $e) { |
||
25 | throw InvalidConfiguration::dotEnvNotFound(File::path()); |
||
26 | } |
||
27 | |||
28 | 6 | $configFiles = Finder::create()->files()->in(File::path('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 | |||
46 | 4 | public static function get(string $key) |
|
50 | |||
51 | 1 | public static function all(): array |
|
55 | } |
||
56 |