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
wmc 2
eloc 4
dl 0
loc 15
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Northwoods\Router;
5
6
use Fig\Http\Message\StatusCodeInterface;
7
use Http\Factory\Discovery\HttpFactory;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Message\ResponseFactoryInterface;
10
use Psr\Http\Message\ResponseInterface;
11
use Psr\Http\Server\RequestHandlerInterface;
12
13
class NotFoundHandler implements RequestHandlerInterface
14
{
15
    /** @var ResponseFactoryInterface */
16
    private $responseFactory;
17
18 9
    public function __construct(
19
        ?ResponseFactoryInterface $responseFactory = null
20
    ) {
21 9
        $this->responseFactory = $responseFactory ?? HttpFactory::responseFactory();
22 9
    }
23
24
    // RequestHandlerInterface
25 1
    public function handle(ServerRequestInterface $request): ResponseInterface
26
    {
27 1
        return $this->responseFactory->createResponse(StatusCodeInterface::STATUS_NOT_FOUND);
28
    }
29
}
30