NotFoundHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 3
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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