protected function responseToArray(ResponseInterface $response): array
    {
        if ($response->getHeaderLine('Content-Type') &&
            0 === strpos($response->getHeaderLine('Content-Type'), 'application/json')) {
            try {
                return (array) $this->jsonDecoder()->decode((string) $response->getBody(), 'json');
            } catch (\UnexpectedValueException $e) {
                throw new InvalidJsonException(
                    $e->getMessage(),
                    $response,
                    $this->getClient()->getJournal()->getLastRequest()
                );
            }
        }
        throw new ApiResponseException(
            $response,
            $this->getClient()->getJournal()->getLastRequest(),
            sprintf('Unable to parse response with %s type. Response body: %s', $response->getHeaderLine('Content-Type') ?: 'unknown', (string) $response->getBody())
        );
    }
protected function responseToArray(ResponseInterface $response): array
    {
        if ($response->getHeaderLine('Content-Type') &&
            0 === strpos($response->getHeaderLine('Content-Type'), 'application/json')) {
            try {
                return (array) $this->jsonDecoder()->decode((string) $response->getBody(), 'json');
            } catch (\UnexpectedValueException $e) {
                throw new InvalidJsonException(
                    $e->getMessage(),
                    $response,
                    $this->getClient()->getJournal()->getLastRequest()
                );
            }
        }
        throw new ApiResponseException(
            $response,
            $this->getClient()->getJournal()->getLastRequest(),
            sprintf('Unable to parse response with %s type. Response body: %s', $response->getHeaderLine('Content-Type') ?: 'unknown', (string) $response->getBody())
        );
    }
protected function responseToArray ( ResponseInterface $ response ) : array { if ( $ response -> getHeaderLine ( 'Content-Type' ) && 0 === strpos ( $ response -> getHeaderLine ( 'Content-Type' ) , 'application/json' ) ) { try { return ( array ) $ this -> jsonDecoder ( ) -> decode ( ( string ) $ response -> getBody ( ) , 'json' ) ; } catch ( \ UnexpectedValueException $ e ) { throw new InvalidJsonException ( $ e -> getMessage ( ) , $ response , $ this -> getClient ( ) -> getJournal ( ) -> getLastRequest ( ) ) ; } } throw new ApiResponseException ( $ response , $ this -> getClient ( ) -> getJournal ( ) -> getLastRequest ( ) , sprintf ( 'Unable to parse response with %s type. Response body: %s' , $ response -> getHeaderLine ( 'Content-Type' ) ? : 'unknown' , ( string ) $ response -> getBody ( ) ) ) ; }
Decodes an Apigee Edge API response to an associative array.

The SDK only works with JSON responses, but let's be prepared for the unexpected.

@param \Psr\Http\Message\ResponseInterface $response

@throws \RuntimeException If response can not be decoded, because the input format is unknown.
@throws \Apigee\Edge\Exception\InvalidJsonException If there was an error with decoding a JSON response.

@return array
Decodes an Apigee Edge API response to an associative array .