We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Total Complexity | 7 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Coverage | 94.12% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | abstract class AbstractConfig |
||
| 13 | { |
||
| 14 | protected const NORMALIZERS = []; |
||
| 15 | |||
| 16 | 38 | public function __construct(array $config) |
|
| 17 | { |
||
| 18 | 38 | $this->populate($config); |
|
| 19 | 38 | } |
|
| 20 | |||
| 21 | 38 | protected function populate(array $config): void |
|
| 22 | { |
||
| 23 | 38 | foreach ($config as $key => $value) { |
|
| 24 | 38 | $property = lcfirst(str_replace('_', '', ucwords($key, '_'))); |
|
| 25 | 38 | $normalizer = static::NORMALIZERS[$property] ?? 'normalize'.ucfirst($property); |
|
| 26 | 38 | if (method_exists($this, $normalizer)) { |
|
| 27 | 38 | $this->$property = $this->$normalizer($value); |
|
| 28 | 38 | } elseif (property_exists($this, $property)) { |
|
| 29 | 38 | $this->$property = $value; |
|
| 30 | } else { |
||
| 31 | throw new InvalidArgumentException(sprintf('Unknown config "%s".', $property)); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | 38 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * @param array|mixed $value |
||
| 38 | */ |
||
| 39 | 32 | protected function normalizeCallback($value): Callback |
|
| 40 | { |
||
| 41 | 32 | return new Callback($value); |
|
| 42 | } |
||
| 43 | |||
| 44 | 3 | protected function normalizeValidation(array $config): Validation |
|
| 47 | } |
||
| 48 | } |
||
| 49 |