ExceptionMiddleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 8 2
1
<?php
2
3
namespace hiapi\Core\Http\Psr15\Middleware;
4
5
use hiapi\Core\Http\Psr7\Response\FatResponse;
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\ServerRequestInterface;
8
use Psr\Http\Server\MiddlewareInterface;
9
use Psr\Http\Server\RequestHandlerInterface;
10
11
class ExceptionMiddleware implements MiddlewareInterface
12
{
13
    /**
14
     * @inheritDoc
15
     */
16
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
17
    {
18
        try {
19
            return $handler->handle($request);
20
        } catch (\Throwable $e) {
21
            return FatResponse::create($e, $request);
22
        }
23
    }
24
}
25