Lines 66.66% 2 / 3
Functions and Methods 0.00% 0 / 1
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
GetDistrictQueryFactory 66.66% 2 / 3 0.00% 0 / 1 2.15 0.00% 0 / 1
 fromRoute 66.66% 2 / 3 0.00% 0 / 1 2.15
1<?php
2
3declare(strict_types=1);
4
5namespace Districts\Editor\UI\Factory;
6
7use Districts\Editor\Application\Query\GetDistrictQuery;
8use Psr\Http\Message\ServerRequestInterface as Request;
9use Slim\Exception\HttpBadRequestException;
10
11final class GetDistrictQueryFactory
12{
13    /**
14     * @param array<string, string> $routeArgs
15     */
16    public function fromRoute(array $routeArgs, Request $request): GetDistrictQuery
17    {
18        if (!array_key_exists("id", $routeArgs)) {
19            throw new HttpBadRequestException($request);
20        }
21
22        return new GetDistrictQuery(intval($routeArgs["id"]));
23    }
24}