@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | $data = json_decode($json, true); |
| 21 | 21 | |
| 22 | 22 | if (!is_array($data)) { |
| 23 | - $data = []; |
|
| 23 | + $data = [ ]; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | return $this->makeFromArray($data); |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public function makeFromArray(array $data): ObjectInterface |
| 30 | 30 | { |
| 31 | - if (!isset($data['object'])) { |
|
| 31 | + if (!isset($data[ 'object' ])) { |
|
| 32 | 32 | throw new InvalidArgumentException('Invalid data format'); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Load class name from map or generate one |
| 36 | - $type = self::CLASS_MAPPING[$data['object']] ?? __NAMESPACE__ . '\\' . ucfirst($data['object']); |
|
| 36 | + $type = self::CLASS_MAPPING[ $data[ 'object' ] ] ?? __NAMESPACE__ . '\\' . ucfirst($data[ 'object' ]); |
|
| 37 | 37 | |
| 38 | 38 | if (!class_exists($type) || !in_array(ObjectInterface::class, class_implements($type), true)) { |
| 39 | 39 | throw new UnexpectedValueException('Unsupported object'); |