| Total Complexity | 4 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | abstract class ConfigObject |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @param array $configValues |
||
| 15 | * @return static |
||
| 16 | */ |
||
| 17 | public static function fromArray(array $configValues) |
||
| 18 | { |
||
| 19 | $config = static::of(); |
||
| 20 | array_walk( |
||
| 21 | $configValues, |
||
| 22 | function ($value, $key) use ($config) { |
||
| 23 | $functionName = 'set' . $config->camelize($key); |
||
| 24 | if (!is_callable([$config, $functionName])) { |
||
| 25 | throw new InvalidArgumentException(sprintf(Message::SETTER_NOT_IMPLEMENTED, $key)); |
||
| 26 | } |
||
| 27 | $config->$functionName($value); |
||
| 28 | } |
||
| 29 | ); |
||
| 30 | |||
| 31 | return $config; |
||
| 32 | } |
||
| 33 | |||
| 34 | protected function camelize($scored) |
||
| 44 | ) |
||
| 45 | ) |
||
| 46 | ) |
||
| 47 | ); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return static |
||
| 52 | */ |
||
| 53 | public static function of() |
||
| 56 | } |
||
| 57 | } |
||
| 58 |