src/Handler/AddressDetailHandler.php
<?php
declare(strict_types=1);
namespace DigipolisGent\Flanders\BasicRegisters\Handler;
use DigipolisGent\API\Client\Handler\HandlerInterface;
use DigipolisGent\API\Client\Response\ResponseInterface;
use DigipolisGent\Flanders\BasicRegisters\Normalizer\FromJson\Address\AddressDetailNormalizer;
use DigipolisGent\Flanders\BasicRegisters\Request\AddressDetailRequest;
use DigipolisGent\Flanders\BasicRegisters\Response\AddressDetailResponse;
use Psr\Http\Message as Psr;
/**
* Handles the AddressDetail request.
*/
final class AddressDetailHandler implements HandlerInterface
{
/**
* @inheritDoc
*/
public function handles(): array
{
return [AddressDetailRequest::class];
}
/**
* @inheritDoc
*/
public function toResponse(Psr\ResponseInterface $response): ResponseInterface
{
$data = json_decode($response->getBody()->getContents());
$normalizer = new AddressDetailNormalizer();
return new AddressDetailResponse(
$normalizer->normalize($data)
);
}
}