Conditions | 4 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public function makeFromArray(array $data): ObjectInterface |
||
30 | { |
||
31 | if (!isset($data['object'])) { |
||
32 | throw new InvalidArgumentException('Invalid data format'); |
||
33 | } |
||
34 | |||
35 | // Load class name from map or generate one |
||
36 | $type = self::CLASS_MAPPING[$data['object']] ?? __NAMESPACE__ . '\\' . ucfirst($data['object']); |
||
37 | |||
38 | if (!class_exists($type) || !in_array(ObjectInterface::class, class_implements($type), true)) { |
||
39 | throw new UnexpectedValueException('Unsupported object'); |
||
40 | } |
||
41 | |||
42 | return $type::fromArray($data); |
||
43 | } |
||
45 |