| Conditions | 6 |
| Paths | 1 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function register(Container $pimple) |
||
| 29 | { |
||
| 30 | $pimple['config.files'] = function ($pimple) { |
||
| 31 | return [$pimple['config.file']]; |
||
| 32 | }; |
||
| 33 | $pimple['config.hydrate'] = $pimple->protect(function ($pimple) { |
||
| 34 | foreach ($pimple['config.files'] as $file) { |
||
| 35 | if (is_file($file) && is_readable($file)) { |
||
| 36 | /** @noinspection PhpIncludeInspection */ |
||
| 37 | $values = require $file; |
||
| 38 | if (is_array($values)) { |
||
| 39 | foreach ($values as $key => $value) { |
||
| 40 | $pimple[$key] = $value; |
||
| 41 | } |
||
| 42 | } else { |
||
| 43 | throw new InvalidArgumentException("Configuration file must return an array"); |
||
| 44 | } |
||
| 45 | } else { |
||
| 46 | throw new RuntimeException("Could not find or read from {$file}"); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | }); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |