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

@return array
974452
protected function parseResponse($response)
    {
        $result = json_decode((string) $response->getBody(), true);

        if (isset($result['exception'])) {
            throw (new DelegationException($result['message']))->setException($result['exception']);
        }

        return $result;
    }
871800
protected function _unserializeResponseBody(ResponseInterface $response) {

		$body = (string) $response->getBody();
		$contentType = $response->getHeaderLine('Content-type');

		try {
			if(false !== stripos($contentType, $this->dataType)
				&& isset($this->unserializers[$this->dataType])) {
				/** @var UnserializerInterface $unserializer */
				$unserializer = \Yii::createObject($this->unserializers[$this->dataType]);
				if($unserializer instanceof UnserializerInterface) {
					return $unserializer->unserialize($body, false);
				}
			}

			return $body;

		} catch(InvalidParamException $e) {

			return $body;
		}
	}
631255
public static function getContent(ResponseInterface $response)
    {
        if ($response->getStatusCode() === 204) {
            return [];
        }

        $body = (string) $response->getBody();

        if (!$body) {
            return [];
        }

        if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) {
            throw new DecodingFailedException('The content type header was not application/json.');
        }

        return self::jsonDecode($body);
    }
137337
private function decodeResponse(ResponseInterface $response): ResponseInterface
    {
        $response = $this->decodeOnEncodingHeader('Transfer-Encoding', $response);

        if ($this->useContentEncoding) {
            $response = $this->decodeOnEncodingHeader('Content-Encoding', $response);
        }

        return $response;
    }
345645
protected function parseResponseIntoArray($response)
    {
        if (!$response->isContentType('json')) {
            parse_str($response->getBody(true), $array);

            return $array;
        }

        return $response->json();
    }
531458
public function response(ResponseInterface $response)
    {
        $this->lastResponse = $response;

        $content = $response->getBody()->getContents();

        $decoded = json_decode($content); // parse as object
        $data = $decoded;

        if (!empty($decoded)) {
            reset($decoded);
            $data = current($decoded); // get first attribute from array, e.g.: subscription, subscriptions, errors.
        }

        $this->checkRateLimit($response)
            ->checkForErrors($response, $data);

        return $data;
    }
653790
protected function parseResponse(ResponseInterface $response): string
    {
        $data = \GuzzleHttp\json_decode($response->getBody(), true);
        isset($data[0]) ? $this->setNotificationData($data) : $this->setData($data);
        $message = sprintf('HTTP %s Error %s', $response->getStatusCode(), $this->data['title']);
        if (isset($this->data['description'])) {
            $message .= sprintf(': %s', $this->getDescription());
        }

        return $message;
    }
683532
protected function getResponseAsJson( ResponseInterface $response ) {
        if( $response->hasHeader('Content-Type') ) {
            $typeHeader = $response->getHeader('Content-Type');
            $contentType = array_shift($typeHeader);

            if( stripos( $contentType, 'application/json' ) === 0 ) {
                return json_decode($response->getBody(), false);
            }
        }

        return null;
    }
491322
public function renderIntoSetCookieHeader(ResponseInterface $response) : ResponseInterface
    {
        $response = $response->withoutHeader(static::SET_COOKIE_HEADER);
        foreach ($this->setCookies as $setCookie) {
            $response = $response->withAddedHeader(static::SET_COOKIE_HEADER, (string) $setCookie);
        }

        return $response;
    }
884714
public function emit(ResponseInterface $response)
    {
        $code = $response->code() . ' ' . $response->reason();

        $headers = $response->headers();

        $version = $response->version();

        foreach ($headers as $name => $values)
        {
            header($name . ': ' . implode(',', $values));
        }

        header(sprintf('HTTP/%s %s', $version, $code));

        return $response;
    }
631164
private function decodeResponse( ResponseInterface $response ) {
		$resultArray = json_decode( $response->getBody(), true );

		$this->logWarnings( $resultArray );
		$this->throwUsageExceptions( $resultArray );

		return $resultArray;
	}
1337846
public function processResponse(ResponseInterface $response)
    {

        $body = $response->getBody();

        $object = json_decode($body);
        if (json_last_error() === JSON_ERROR_NONE) {
            // JSON is valid
            if (property_exists($object, '_embedded') && property_exists($object->_embedded, 'items')) {
                $return = $object->_embedded->items;
            } elseif (property_exists($object, 'error')) {
                if (is_array($object->message)) {
                    foreach ($object->message as $message) {
                        $output .= $message;
                    }
                    throw new \Exception($output);
                } else {
                    throw new \Exception($object->message);
                }
            } else {
                $return = $object;
            }
        } else {
            $return = $body;
        }

        return $return;
    }
1136103
private function getBodyAsArray(ResponseInterface $response): array
    {
        if ($this->responseContentTypeIsJson($response)) {
            $response->getBody()->rewind();
            $body = null;

            if ($response->getBody()->getSize() > 0) {
                $body = $response->getBody()->getContents();
            }

            return \json_decode($body, true);
        }

        throw new \InvalidArgumentException('Response from Firebase Cloud Messaging is not a JSON');
    }
764081
private function getResult($response)
    {
        $status = $response->getStatusCode();
        if ($status == 200) {
            return json_decode($response->getBody(), JSON_PRETTY_PRINT);
        } else {
            return [$status => $response->getReasonPhrase()];
        }
    }
372368
protected function extractMetaData(ResponseInterface $response)
    {
        $headers = $this->findMetaHeaders($response);

        if (!count($headers)) {
            return [];
        }

        $metaData = [];

        foreach ($headers as $header) {
            $metaData[$header] = $response->getHeaderLine($header);
        }

        return $metaData;
    }
838465
protected function listResponseHeaders(ResponseInterface $response):\Generator
    {
        foreach ($response->getHeaders() as $header => $values) {
            foreach ($values as $value) {
                yield $header => $value;
            }
        }
    }
130303
protected function createLaravelResponse(ResponseInterface $response)
    {
        return new Response(
            (string) $response->getBody(),
            $response->getStatusCode(),
            $response->getHeaders()
        );
    }