NotFoundHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 6 1
A __construct() 0 4 1
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