| Conditions | 6 |
| Paths | 10 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | function config($key = null, $default = null) |
||
| 17 | { |
||
| 18 | $container = function_exists('app') ? app() : Container::getInstance(); |
||
| 19 | if (!$container) { |
||
| 20 | /** @noinspection PhpUnhandledExceptionInspection */ |
||
| 21 | throw new Exception("No container was found for config function"); |
||
| 22 | } |
||
| 23 | |||
| 24 | $config = $container->get('config'); |
||
| 25 | if (!$config) { |
||
| 26 | /** @noinspection PhpUnhandledExceptionInspection */ |
||
| 27 | throw new Exception("No Config was found in the container"); |
||
| 28 | } |
||
| 29 | |||
| 30 | if (is_null($key)) { |
||
| 31 | return $config; |
||
| 32 | } |
||
| 33 | if (is_array($key)) { |
||
| 34 | return $config->set($key); |
||
| 35 | } |
||
| 36 | |||
| 37 | return $config->get($key, $default); |
||
| 38 | } |
||
| 39 | } |
||
| 40 |