| Total Complexity | 10 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 6 | class Config |
||
| 7 | { |
||
| 8 | private $config; |
||
| 9 | private $logger; |
||
| 10 | |||
| 11 | public function __construct(array $customConfig = null) |
||
| 12 | { |
||
| 13 | |||
| 14 | |||
| 15 | if( $customConfig===null){ |
||
| 16 | $paths = [ |
||
| 17 | dirname(__DIR__, 2) . '/viva-config.php', |
||
| 18 | dirname(__DIR__, 5) . '/viva-config.php' |
||
| 19 | ]; |
||
| 20 | $this->config = $this->loadConfigFile($paths); |
||
| 21 | |||
| 22 | }else{ |
||
| 23 | |||
| 24 | $this->config = $customConfig; |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | public function getConfig(): array { |
||
| 29 | return $this->config; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function get($key) |
||
| 35 | } |
||
| 36 | |||
| 37 | public function getEnvConfig($key) |
||
| 38 | { |
||
| 39 | $env = $this->config['defaultProvider']; |
||
| 40 | return $this->config[$env][$key] ?? null; |
||
| 41 | } |
||
| 42 | |||
| 43 | |||
| 44 | private function loadConfigFile(array $paths) |
||
| 62 | } |
||
| 63 | } |
||
| 64 |