| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public function decode(string $data): array |
||
| 20 | { |
||
| 21 | $decoded = $json = json_decode($data, true); |
||
|
|
|||
| 22 | |||
| 23 | if (JSON_ERROR_NONE !== json_last_error()) { |
||
| 24 | throw DeserializerRuntimeException::createNotParsable($this->getContentType(), json_last_error_msg()); |
||
| 25 | } |
||
| 26 | 4 | ||
| 27 | if (!is_array($decoded)) { |
||
| 28 | 4 | throw DeserializerRuntimeException::createNotParsable($this->getContentType(), 'Not an object'); |
|
| 29 | } |
||
| 30 | 4 | ||
| 31 | 1 | return $decoded; |
|
| 32 | } |
||
| 34 |