HttpExceptionMiddleware   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 17
ccs 7
cts 8
cp 0.875
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 5
1
<?php
2
declare(strict_types=1);
3
4
namespace Ctw\Middleware\HttpExceptionMiddleware;
5
6
use Ctw\Http\HttpException;
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Server\RequestHandlerInterface;
10
use Throwable;
11
12
class HttpExceptionMiddleware extends AbstractHttpExceptionMiddleware
13
{
14 4
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
15
    {
16
        try {
17 4
            return $handler->handle($request);
18 4
        } catch (Throwable $throwable) {
19
            // continue;
20
        }
21
22 4
        if (!$this->isDevelopmentMode() && $throwable instanceof HttpException\HttpExceptionInterface) {
23 4
            return $this->asJson($request)
24 2
                ? $this->getJsonResponse($throwable)
25 4
                : $this->getHtmlResponse($throwable);
26
        }
27
28
        throw $throwable;
29
    }
30
}
31