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 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| RemoveDistrictCommandFactory | 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 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Districts\Editor\UI\Factory; | |
| 6 | ||
| 7 | use Districts\Editor\Application\Command\RemoveDistrictCommand; | |
| 8 | use Psr\Http\Message\ServerRequestInterface as Request; | |
| 9 | use Slim\Exception\HttpBadRequestException; | |
| 10 | ||
| 11 | final class RemoveDistrictCommandFactory | |
| 12 | { | |
| 13 | /** | |
| 14 | * @param array<string, string> $routeArgs | |
| 15 | */ | |
| 16 | public function fromRoute(array $routeArgs, Request $request): RemoveDistrictCommand | |
| 17 | { | |
| 18 | if (!array_key_exists("id", $routeArgs)) { | |
| 19 | throw new HttpBadRequestException($request); | |
| 20 | } | |
| 21 | ||
| 22 | return new RemoveDistrictCommand(intval($routeArgs["id"])); | |
| 23 | } | |
| 24 | } |