@@ -59,7 +59,8 @@ |
||
| 59 | 59 | |
| 60 | 60 | public function addLoader(string $ext, FileLoaderInterface $loader): void |
| 61 | 61 | { |
| 62 | - if (!isset($this->loaders[$ext]) || get_class($this->loaders[$ext]) !== get_class($loader)) { |
|
| 62 | + if (!isset($this->loaders[$ext]) || get_class($this->loaders[$ext]) !== get_class($loader)) |
|
| 63 | + { |
|
| 63 | 64 | $this->loaders[$ext] = $loader; |
| 64 | 65 | $this->container->bindSingleton(ConfigManager::class, $this->createConfigManager()); |
| 65 | 66 | } |
@@ -37,9 +37,11 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function has(string $section): bool |
| 39 | 39 | { |
| 40 | - foreach ($this->loaderExtensions() as $extension) { |
|
| 40 | + foreach ($this->loaderExtensions() as $extension) |
|
| 41 | + { |
|
| 41 | 42 | $filename = sprintf('%s/%s.%s', $this->directory, $section, $extension); |
| 42 | - if (file_exists($filename)) { |
|
| 43 | + if (file_exists($filename)) |
|
| 44 | + { |
|
| 43 | 45 | return true; |
| 44 | 46 | } |
| 45 | 47 | } |
@@ -52,15 +54,20 @@ discard block |
||
| 52 | 54 | */ |
| 53 | 55 | public function load(string $section): array |
| 54 | 56 | { |
| 55 | - foreach ($this->loaderExtensions() as $extension) { |
|
| 57 | + foreach ($this->loaderExtensions() as $extension) |
|
| 58 | + { |
|
| 56 | 59 | $filename = sprintf('%s/%s.%s', $this->directory, $section, $extension); |
| 57 | - if (!file_exists($filename)) { |
|
| 60 | + if (!file_exists($filename)) |
|
| 61 | + { |
|
| 58 | 62 | continue; |
| 59 | 63 | } |
| 60 | 64 | |
| 61 | - try { |
|
| 65 | + try |
|
| 66 | + { |
|
| 62 | 67 | return $this->getLoader($extension)->loadFile($section, $filename); |
| 63 | - } catch (LoaderException $e) { |
|
| 68 | + } |
|
| 69 | + catch (LoaderException $e) |
|
| 70 | + { |
|
| 64 | 71 | throw new LoaderException("Unable to load config `{$section}`.", $e->getCode(), $e); |
| 65 | 72 | } |
| 66 | 73 | } |