NotFoundHandler::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Http;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Server\RequestHandlerInterface;
10
use Yiisoft\DataResponse\DataResponseFactoryInterface;
11
use Yiisoft\DataResponse\DataResponseFormatterInterface;
12
use Yiisoft\Http\Status;
13
14
final class NotFoundHandler implements RequestHandlerInterface
15
{
16
    public function __construct(
17
        private DataResponseFormatterInterface $formatter,
18
        private DataResponseFactoryInterface $dataResponseFactory,
19
    ) {
20
    }
21
22
    public function handle(ServerRequestInterface $request): ResponseInterface
23
    {
24
        return $this->formatter->format(
25
            $this->dataResponseFactory->createResponse(
26
                'Not found.',
27
                Status::NOT_FOUND,
28
            )
29
        );
30
    }
31
}
32