Lines
100.00%
10 / 10
Methods
100.00%
2 / 2
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| __invoke | 100.00% | 9 / 9 | 100.00% | 1 / 1 | 1 | ||
| 13 | final readonly class AddFormController | |
| 14 | { | |
| 15 | public function __construct( | |
| 16 | private CityIterator $cityIterator, | |
| 17 | private Session $session, | |
| 18 | private View $view, | |
| 19 | ) { | |
| 20 | } | |
| 21 | ||
| 22 | /** | |
| 23 | * @param array<string, string> $args | |
| 24 | */ | |
| 25 | // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter | |
| 26 | public function __invoke(Request $request, Response $response, array $args): Response | |
| 27 | { | |
| 28 | $cities = iterator_to_array($this->cityIterator); | |
| 29 | $templateData = [ | |
| 30 | "title" => "Add a district", | |
| 31 | "cities" => $cities, | |
| 32 | "district" => $this->session->getAndDelete("form.add.values"), | |
| 33 | "errors" => $this->session->getAndDelete("form.add.errors"), | |
| 34 | "errorMessage" => $this->session->getAndDelete("form.add.error.message"), | |
| 35 | ]; | |
| 36 | return $this->view->render($response, "add.html", $templateData); | |
| 37 | } | |
| 38 | } |