Passed
Pull Request — master (#188)
by Wilmer
02:48
created

NotFoundHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
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 2
    public function __construct(
17
        private DataResponseFormatterInterface $formatter,
18
        private DataResponseFactoryInterface $dataResponseFactory,
19
    ) {
20 2
    }
21
22 1
    public function handle(ServerRequestInterface $request): ResponseInterface
23
    {
24 1
        return $this->formatter->format(
25 1
            $this->dataResponseFactory->createResponse(
26 1
                'Not found.',
27 1
                Status::NOT_FOUND,
28 1
            )
29 1
        );
30
    }
31
}
32