| Total Complexity | 4 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class Config extends ArrayObject |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Construct a new config |
||
| 13 | * |
||
| 14 | * @param string $filename |
||
| 15 | * @return void |
||
| 16 | */ |
||
| 17 | 2 | public function __construct(array $input = []) |
|
| 18 | { |
||
| 19 | 2 | parent::__construct($input + [ |
|
| 20 | // 'workdir' => getcwd(), |
||
| 21 | 2 | 'port' => 9501, |
|
| 22 | 'events' => [], |
||
| 23 | ]); |
||
| 24 | 2 | $this->sanitize(); |
|
| 25 | 1 | } |
|
| 26 | |||
| 27 | /** |
||
| 28 | * load config.yaml |
||
| 29 | * |
||
| 30 | * @param string $filename |
||
| 31 | * @return void |
||
| 32 | */ |
||
| 33 | 1 | public function loadYaml(string $filename) |
|
| 34 | { |
||
| 35 | 1 | $config = Yaml::parseFile($filename); |
|
| 36 | 1 | $this->exchangeArray($config + $this->getArrayCopy()); |
|
| 37 | 1 | $this->sanitize(); |
|
| 38 | 1 | } |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Sanitize config values. |
||
| 42 | * |
||
| 43 | * @return void |
||
| 44 | * |
||
| 45 | * @throws \InvalidArgumentException |
||
| 46 | */ |
||
| 47 | 2 | private function sanitize(): void |
|
| 59 | } |
||
| 60 | } |