Passed
Push — master ( 8241e4...1bc467 )
by Alexander
03:14
created

NotFoundHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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
14
final class NotFoundHandler implements RequestHandlerInterface
15
{
16
    private DataResponseFormatterInterface $formatter;
17
    private DataResponseFactoryInterface $dataResponseFactory;
18
19 14
    public function __construct(DataResponseFormatterInterface $formatter, DataResponseFactoryInterface $dataResponseFactory)
20
    {
21 14
        $this->formatter = $formatter;
22 14
        $this->dataResponseFactory = $dataResponseFactory;
23 14
    }
24
25 1
    public function handle(ServerRequestInterface $request): ResponseInterface
26
    {
27 1
        return $this->formatter->format(
28 1
            $this->dataResponseFactory->createResponse('Page not found', Status::NOT_FOUND)
29
        );
30
    }
31
}
32