| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| 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 | |||
| 27 | throw new \BadMethodCallException($message.$response->getHeaderLine(self::HEADER_CONTENT_TYPE)); |
||
| 28 | } |
||
| 29 | |||
| 30 | $body = $this->getBodyContent($response); |
||
| 31 | if (JSON_ERROR_NONE !== \json_last_error()) { |
||
| 32 | throw new \BadMethodCallException(sprintf( |
||
| 33 | 'Error (%d) when trying to json_decode response: %s', |
||
| 34 | \json_last_error(), |
||
| 35 | \json_last_error_msg() |
||
| 36 | )); |
||
| 37 | } |
||
| 38 | |||
| 39 | return $body; |
||
|
|
|||
| 40 | } |
||
| 42 |