Code Duplication    Length = 3-3 lines in 2 locations

src/Hydrator/ArrayHydrator.php 1 location

@@ 30-32 (lines=3) @@
27
    public function hydrate(ResponseInterface $response, string $class): array
28
    {
29
        $body = $response->getBody()->__toString();
30
        if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) {
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()));

src/Hydrator/ModelHydrator.php 1 location

@@ 32-34 (lines=3) @@
29
    public function hydrate(ResponseInterface $response, string $class)
30
    {
31
        $body = $response->getBody()->__toString();
32
        if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) {
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()));