Conditions | 4 |
Paths | 6 |
Total Lines | 22 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php declare(strict_types = 1); |
||
20 | 4 | public function process(ServerRequestInterface $request, DelegateInterface $delegate) : ResponseInterface |
|
21 | { |
||
22 | 4 | $controller = $request->getAttribute('controller'); |
|
23 | |||
24 | 4 | if ($controller instanceof RequestFilterInterface) { |
|
25 | // Execute the request-filter from the controller |
||
26 | 1 | $request = $controller->filterRequest($request); |
|
27 | } |
||
28 | |||
29 | 4 | if ($controller instanceof RequestValidatorInterface) { |
|
30 | // Execute the request-validator from the controller |
||
31 | try { |
||
32 | 2 | $controller->validateRequest($request); |
|
33 | 1 | } catch (ValidationFailedException $exception) { |
|
34 | // Hand of to error-handler on failure |
||
35 | 1 | return ($this->errorHandler)($request, $exception); |
|
36 | } |
||
37 | } |
||
38 | |||
39 | // Filtered and validated (if applicable), let's continue on |
||
40 | 3 | return $delegate->next($request); |
|
41 | } |
||
42 | } |
||
43 |