hetzner-dns-api/generated/Runtime/Client/EndpointTrait.php

15 lines
715 B
PHP
Raw Normal View History

2023-01-05 12:55:52 +01:00
<?php
namespace DigiComp\HetznerDnsApi\Runtime\Client;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\Serializer\SerializerInterface;
trait EndpointTrait
{
protected abstract function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null);
public function parseResponse(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT)
{
$contentType = $response->hasHeader('Content-Type') ? current($response->getHeader('Content-Type')) : null;
return $this->transformResponseBody((string) $response->getBody(), $response->getStatusCode(), $serializer, $contentType);
}
}