Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| NotFoundHandler | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Web\NotFound; |
| 6 | |
| 7 | use Psr\Http\Message\ResponseInterface; |
| 8 | use Psr\Http\Message\ServerRequestInterface; |
| 9 | use Psr\Http\Server\RequestHandlerInterface; |
| 10 | use Yiisoft\Http\Status; |
| 11 | use Yiisoft\Router\CurrentRoute; |
| 12 | use Yiisoft\Router\UrlGeneratorInterface; |
| 13 | use Yiisoft\Yii\View\Renderer\WebViewRenderer; |
| 14 | |
| 15 | class NotFoundHandler implements RequestHandlerInterface |
| 16 | { |
| 17 | public function __construct( |
| 18 | private UrlGeneratorInterface $urlGenerator, |
| 19 | private CurrentRoute $currentRoute, |
| 20 | private WebViewRenderer $viewRenderer, |
| 21 | ) {} |
| 22 | |
| 23 | public function handle(ServerRequestInterface $request): ResponseInterface |
| 24 | { |
| 25 | return $this->viewRenderer |
| 26 | ->render(__DIR__ . '/template', ['urlGenerator' => $this->urlGenerator, 'currentRoute' => $this->currentRoute]) |
| 27 | ->withStatus(Status::NOT_FOUND); |
| 28 | } |
| 29 | } |