| Code Coverage | ||||||||||
| Classes and Traits | Functions and Methods | Lines | ||||||||
| Total |  | 100.00% | 1 / 1 |  | 100.00% | 2 / 2 | CRAP |  | 100.00% | 5 / 5 | 
| GetCityQueryHandler |  | 100.00% | 1 / 1 |  | 100.00% | 2 / 2 | 2 |  | 100.00% | 5 / 5 | 
| __construct |  | 100.00% | 1 / 1 | 1 |  | 100.00% | 2 / 2 | |||
| __invoke |  | 100.00% | 1 / 1 | 1 |  | 100.00% | 3 / 3 | |||
| 1 | <?php | 
| 2 | |
| 3 | namespace App\Infrastructure; | 
| 4 | |
| 5 | use App\Application\CityResponse; | 
| 6 | use App\Application\GetCityQuery; | 
| 7 | use App\Application\QueryHandler; | 
| 8 | use App\Domain\City; | 
| 9 | use Symfony\Component\HttpFoundation\Request; | 
| 10 | use Symfony\Component\Serializer\SerializerInterface; | 
| 11 | use Symfony\Contracts\HttpClient\HttpClientInterface; | 
| 12 | |
| 13 | class GetCityQueryHandler implements QueryHandler | 
| 14 | { | 
| 15 | public function __construct( | 
| 16 | private HttpClientInterface $musementClient, | 
| 17 | private SerializerInterface $serializer, | 
| 18 | ) { | 
| 19 | } | 
| 20 | |
| 21 | public function __invoke(GetCityQuery $query): CityResponse | 
| 22 | { | 
| 23 | $request = $this->musementClient->request(Request::METHOD_GET, '/api/v3/cities'); | 
| 24 | |
| 25 | /** @var City[] $response */ | 
| 26 | $response = $this->serializer->deserialize($request->getContent(), City::class.'[]', 'json'); | 
| 27 | |
| 28 | return new CityResponse($response); | 
| 29 | } | 
| 30 | } |