RoutingErrorResponder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 12
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 4 1
A respond() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Routing;
5
6
use N1215\Http\Router\Exception\RouteNotFoundException;
7
use N1215\Http\Router\Exception\RoutingException;
8
use N1215\Http\Router\Handler\RoutingErrorResponderInterface;
9
use Psr\Http\Message\ResponseInterface;
10
use Psr\Http\Message\ServerRequestInterface;
11
use Laminas\Diactoros\Response\JsonResponse;
12
13
class RoutingErrorResponder implements RoutingErrorResponderInterface
14
{
15
    public function supports(RoutingException $exception): bool
16
    {
17
        return $exception instanceof RouteNotFoundException;
18
    }
19
20 1
    public function respond(RoutingException $exception, ServerRequestInterface $request): ResponseInterface
21
    {
22 1
        return new JsonResponse(['message' => $exception->getMessage()], 404);
23
    }
24
}
25