| Conditions | 3 |
| Paths | 3 |
| Total Lines | 10 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public function hydrate(ResponseInterface $response, string $class): array |
||
| 17 | { |
||
| 18 | if (0 !== strpos($response->getHeaderLine('Content-Type'), 'application/json')) { |
||
| 19 | throw new HydrationException('The ArrayHydrator cannot hydrate response with Content-Type:'.$response->getHeaderLine('Content-Type')); |
||
| 20 | } |
||
| 21 | |||
| 22 | try { |
||
| 23 | return Json::decode((string) $response->getBody(), true); |
||
| 24 | } catch (\JsonException $exception) { |
||
| 25 | throw new HydrationException(sprintf('Error when trying to decoding the JSON response: %s', $exception->getMessage()), 0, $exception); |
||
| 26 | } |
||
| 29 |