| @@ 30-32 (lines=3) @@ | ||
| 27 | public function hydrate(ResponseInterface $response, string $class): array |
|
| 28 | { |
|
| 29 | $body = $response->getBody()->__toString(); |
|
| 30 | if (0 !== strpos($response->getHeaderLine('Content-Type'), 'application/json')) { |
|
| 31 | throw new HydrationException('The ArrayHydrator cannot hydrate response with Content-Type:'.$response->getHeaderLine('Content-Type')); |
|
| 32 | } |
|
| 33 | $content = json_decode($body, true); |
|
| 34 | if (JSON_ERROR_NONE !== json_last_error()) { |
|
| 35 | throw new HydrationException(sprintf('Error (%d) when trying to json_decode response', json_last_error())); |
|
| @@ 32-34 (lines=3) @@ | ||
| 29 | public function hydrate(ResponseInterface $response, string $class) |
|
| 30 | { |
|
| 31 | $body = $response->getBody()->__toString(); |
|
| 32 | if (0 !== strpos($response->getHeaderLine('Content-Type'), 'application/json')) { |
|
| 33 | throw new HydrationException('The ModelHydrator cannot hydrate response with Content-Type:'.$response->getHeaderLine('Content-Type')); |
|
| 34 | } |
|
| 35 | $data = 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())); |
|