@param ResponseInterface $response
@param Span              $originalSpan

@return Span
765884
public function fromIncomingResponse(Span $originalSpan, ResponseInterface $response = null)
    {
        return new Span(
            $originalSpan->getIdentifier(),
            $originalSpan->getName(),
            $originalSpan->getTraceIdentifier(),
            [
                new Annotation(Annotation::CLIENT_RECEIVE, $this->clock->microseconds(), $this->endpointResolver->resolve()),
            ],
            [
                new BinaryAnnotation('http.status', $response !== null ? $response->getStatusCode() : 0, BinaryAnnotation::TYPE_INTEGER_16),
            ],
            $originalSpan->getParentIdentifier(),
            $originalSpan->getDebug()
        );
    }
245063
public static function factory(RequestInterface $request, Response $response)
    {
        $message = 'Client error response' . PHP_EOL . implode(PHP_EOL, array(
            '[status code] ' . $response->getStatusCode(),
            '[reason phrase] ' . $response->getReasonPhrase(),
            '[url] ' . $request->getUrl(),
        ));

        $e = new static($message);
        $e->setResponse($response);
        $e->setRequest($request);

        return $e;
    }
881059
protected function getBody( ResponseInterface $response ) {
		$body = $response->getBody();
		if ( $body->isSeekable() ) {
			$body->rewind();
		}
		return $body;
	}
927784
protected function finalizeResponse(ResponseInterface $response) : ResponseInterface
    {
        // stop PHP sending a Content-Type automatically
        ini_set('default_mimetype', '');
        if ($this->isEmptyResponseCode($response->getStatusCode())) {
            return $response->withoutHeader('Content-Type')->withoutHeader('Content-Length');
        }

        return $response;
    }
1319241
protected function updateResponseTransfer(AdyenApiResponseTransfer $responseTransfer, array $response): AdyenApiResponseTransfer
    {
        $apiResponseTransfer = (new AdyenApiCancelOrRefundResponseTransfer())->fromArray($response, true);

        return $responseTransfer->setCancelOrRefundResponse($apiResponseTransfer);
    }
39960
private function withText(ResponseInterface $response, $text)
    {
        if (is_array($text)) {
            $text = implode(PHP_EOL, $text);
        }

        return $this
            ->withNewBody($response, $text)
            ->withHeader('Content-Type', 'text/plain');
    }
885054
public static function fromResponse(ResponseInterface $response, $message = null)
    {
        throw new static($message, $response->getStatusCode(), (string) $response->getBody());
    }
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;
    }
673600
protected function updateResponseTransfer(AdyenApiResponseTransfer $responseTransfer, array $response): AdyenApiResponseTransfer
    {
        $apiResponseTransfer = (new AdyenApiAuthorizeResponseTransfer())->fromArray($response, true);

        return $responseTransfer->setAuthorizeResponse($apiResponseTransfer);
    }
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;
		}
	}
130303
protected function createLaravelResponse(ResponseInterface $response)
    {
        return new Response(
            (string) $response->getBody(),
            $response->getStatusCode(),
            $response->getHeaders()
        );
    }
631037
static function decodeBody(\Psr\Http\Message\ResponseInterface $response) {
        $body = (string) $response->getBody();
        
        $type = $response->getHeader('Content-Type')[0];
        if(\stripos($type, 'text/html') !== false) {
            throw new \RuntimeException('Invalid API response: HTML response body received');
        }
        
        $json = \json_decode($body, true, 512, self::$jsonOptions);
        if($json === null && \json_last_error() !== \JSON_ERROR_NONE) {
            throw new \RuntimeException('Invalid API response: '.\json_last_error_msg());
        }
        
        return $json;
    }
354767
protected function appendAllResponse(ResponseInterface $response): ResponseInterface
    {
        if ($this->append) {
            $this->cors->setResponse('psr-7', $response);
            $this->cors->handle();

            return $this->cors->getResponse();
        }

        return $response;
    }
793516
public static function fromResponse(Response $response)
    {
        $header = $response->headers->get('Link');
        if (is_array($header)) {
            implode(',', $header);
        }

        return self::fromString($header);
    }
125982
protected function updateResponseTransfer(AdyenApiResponseTransfer $responseTransfer, array $response): AdyenApiResponseTransfer
    {
        $apiResponseTransfer = (new AdyenApiMakePaymentResponseTransfer())->fromArray($response, true);

        return $responseTransfer->setMakePaymentResponse($apiResponseTransfer);
    }
922057
protected function getBodyContent(ResponseInterface $response)
    {
        $body    = $response->getBody();
        $headers = $response->getHeaders();

        return $this->createContent($headers, $body);
    }
245865
public function handleResponse(ResponseInterface $response, ApiResourceInterface $owner)
    {
        $json = json_decode((string) $response->getBody(), true);
        $data = $this->getItemsFromJsonResponse($json);

        if (is_null($data)) {
            throw new \InvalidArgumentException('Given response is not a '.$this->resourcePath().' response.');
        }

        return $this->createResourcesFromJsonData($data, $response, $owner);
    }