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