1 | <?php |
||
13 | class Config |
||
14 | { |
||
15 | protected static $env; |
||
16 | protected static $loadedConfiguration = []; |
||
17 | |||
18 | 7 | public static function init() |
|
19 | { |
||
20 | 7 | self::$env = new Dotenv(File::path()); |
|
21 | |||
22 | try { |
||
23 | 7 | self::$env->load(); |
|
24 | } catch (InvalidPathException $e) { |
||
25 | throw InvalidConfiguration::dotEnvNotFound(File::path()); |
||
26 | } |
||
27 | |||
28 | 7 | $configurationFiles = Finder::create()->files()->in(File::path('config'))->name('*.php')->getIterator(); |
|
29 | |||
30 | 7 | self::loadDefaults(); |
|
31 | |||
32 | 7 | $loadedConfiguration = self::load($configurationFiles); |
|
|
|||
33 | |||
34 | 7 | self::$loadedConfiguration = array_merge(self::$loadedConfiguration, Arr::dot($loadedConfiguration)); |
|
35 | 7 | } |
|
36 | |||
37 | 4 | public static function get(string $key) |
|
41 | |||
42 | 2 | public static function all(): array |
|
46 | |||
47 | 7 | protected static function loadDefaults(): void |
|
52 | |||
53 | 7 | protected static function load(Iterator $configurationFiles): array |
|
69 | } |
||
70 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.