Code Duplication    Length = 8-9 lines in 2 locations

src/Api/AbstractApi.php 1 location

@@ 104-112 (lines=9) @@
101
            return $this->getInstapushClient()->getTransformer()->transform($response, Error::class);
102
        }
103
104
        if (0 !== \strpos($response->getHeaderLine('Content-Type'), 'application/json')) {
105
            throw new ApiException(
106
                \sprintf(
107
                    'Waiting for json response but %s given',
108
                    $response->getHeaderLine('Content-Type')
109
                ),
110
                500
111
            );
112
        }
113
114
        $content = \json_decode($response->getBody()->getContents(), true);
115

src/Transformer/ModelTransformer.php 1 location

@@ 27-34 (lines=8) @@
24
     */
25
    public function transform(ResponseInterface $response, string $class)
26
    {
27
        if (0 !== \strpos($response->getHeaderLine('Content-Type'), 'application/json')) {
28
            throw new TransformerException(
29
                \sprintf(
30
                    'The ModelTransformer can transform json response but %s given',
31
                    $response->getHeaderLine('Content-Type')
32
                )
33
            );
34
        }
35
36
        $body = $response->getBody()->__toString();
37
        $data = \json_decode($body, true);