| Total Complexity | 7 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 86.36% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | trait ToArray |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @param string $name |
||
| 15 | * @return Property|null |
||
| 16 | * @throws RuntimeException |
||
| 17 | */ |
||
| 18 | 23 | private function getProperty(string $name): ?Property |
|
| 19 | { |
||
| 20 | 23 | $cases = Property::cases(); |
|
| 21 | 23 | $key = \array_search($name, \array_column($cases, 'value')); |
|
| 22 | |||
| 23 | 23 | $property = Property::tryFrom($cases[$key]->value); |
|
| 24 | |||
| 25 | 23 | if (! $property instanceof Property) { |
|
| 26 | throw new RuntimeException( |
||
| 27 | \sprintf('Property % can not be found', $name) |
||
| 28 | ); |
||
| 29 | } |
||
| 30 | |||
| 31 | 23 | return $property; |
|
| 32 | } |
||
| 33 | |||
| 34 | 26 | public function toArray(): array |
|
| 57 | } |
||
| 58 | } |
||
| 59 |