ErrorHandlerMiddleware::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace HttpSoft\ErrorHandler;
6
7
use ErrorException;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Psr\Http\Server\MiddlewareInterface;
11
use Psr\Http\Server\RequestHandlerInterface;
12
13
final class ErrorHandlerMiddleware implements MiddlewareInterface
14
{
15
    use ErrorHandlerTrait;
16
17
    /**
18
     * @param ErrorResponseGeneratorInterface|null $responseGenerator
19
     */
20 13
    public function __construct(?ErrorResponseGeneratorInterface $responseGenerator = null)
21
    {
22 13
        $this->responseGenerator = $responseGenerator ?? new ErrorResponseGenerator();
23
    }
24
25
    /**
26
     * @param ServerRequestInterface $request
27
     * @param RequestHandlerInterface $handler
28
     * @return ResponseInterface
29
     * @throws ErrorException
30
     */
31 13
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
32
    {
33 13
        return $this->handleError($request, $handler);
34
    }
35
}
36