NotFoundHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Handler;
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
use Yiisoft\Translator\TranslatorInterface;
14
15
final class NotFoundHandler implements RequestHandlerInterface
16
{
17
    public function __construct(
18
        private DataResponseFormatterInterface $formatter,
19 14
        private DataResponseFactoryInterface $dataResponseFactory,
20
        private TranslatorInterface $translator,
21 14
    ) {
22 14
    }
23
24
    public function handle(ServerRequestInterface $request): ResponseInterface
25 1
    {
26
        return $this->formatter->format(
27 1
            $this->dataResponseFactory->createResponse(
28 1
                $this->translator->translate('404.title'),
29
                Status::NOT_FOUND,
30
            )
31
        );
32
    }
33
}
34