| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | public function hydrate(ResponseInterface $response, string $class): array |
||
| 29 | { |
||
| 30 | $body = $response->getBody()->__toString(); |
||
| 31 | if (0 !== strpos($response->getHeaderLine('Content-Type'), 'application/json')) { |
||
| 32 | throw new HydrationException('The ArrayHydrator cannot hydrate response with Content-Type:'.$response->getHeaderLine('Content-Type')); |
||
| 33 | } |
||
| 34 | |||
| 35 | $content = json_decode($body, true); |
||
| 36 | if (JSON_ERROR_NONE !== json_last_error()) { |
||
| 37 | throw new HydrationException(sprintf('Error (%d) when trying to json_decode response', json_last_error())); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $content; |
||
| 41 | } |
||
| 43 |