Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function hydrate(ResponseInterface $response, string $class = null): array |
||
24 | { |
||
25 | if (!$this->isJsonResponse($response)) { |
||
26 | $message = 'The ArrayHydrator cannot hydrate a response with Content-Type: '; |
||
27 | |||
28 | throw new HydrationException($message.$response->getHeaderLine(self::HEADER_CONTENT_TYPE)); |
||
29 | } |
||
30 | |||
31 | $body = $this->getBodyContent($response); |
||
32 | if (JSON_ERROR_NONE !== \json_last_error()) { |
||
33 | throw new HydrationException(sprintf( |
||
34 | 'Error (%d) when trying to json_decode response: %s', |
||
35 | \json_last_error(), |
||
36 | \json_last_error_msg() |
||
37 | )); |
||
38 | } |
||
39 | |||
40 | return $body; |
||
|
|||
41 | } |
||
43 |