| Conditions | 3 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function hydrate(ResponseInterface $response, $class) |
||
| 29 | { |
||
| 30 | $body = $response->getBody()->__toString(); |
||
| 31 | if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) { |
||
| 32 | throw new DeserializeException('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 DeserializeException(sprintf('Error (%d) when trying to json_decode response', json_last_error())); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $content; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |