| Total Complexity | 9 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | class Config |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * The config. |
||
| 22 | * |
||
| 23 | * @since 1.0.0 |
||
| 24 | * |
||
| 25 | * @var array The config array. |
||
| 26 | */ |
||
| 27 | protected $config = []; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Factory class. |
||
| 31 | * |
||
| 32 | * @since 1.0.0 |
||
| 33 | * |
||
| 34 | * @param array $options The defaut configuration option. |
||
| 35 | * |
||
| 36 | * @return void |
||
| 37 | */ |
||
| 38 | public function __construct($options = []) |
||
| 39 | { |
||
| 40 | $dir = __DIR__.'/../../../../../../'; |
||
| 41 | |||
| 42 | if (!empty($options) && isset($options['paths']['root'])) { |
||
| 43 | $dir = rtrim($options['paths']['root'], '/').'/'; |
||
| 44 | } |
||
| 45 | |||
| 46 | foreach (glob($dir.'config/*.php') as $file) { |
||
| 47 | $index = pathinfo($file)['filename']; |
||
| 48 | $this->config[$index] = require_once $file; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Get the config value. |
||
| 54 | * |
||
| 55 | * @since 1.0.0 |
||
| 56 | * |
||
| 57 | * @param string $config The config key. |
||
| 58 | * @param string $default The default config value. |
||
| 59 | * |
||
| 60 | * @return null|string |
||
| 61 | */ |
||
| 62 | public function get($config, $default = null) |
||
| 81 | } |
||
| 82 | } |
||
| 83 |