ErrorHandlerMiddlewareFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 13
ccs 4
cts 4
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\Http;
6
7
use Devanych\Di\FactoryInterface;
8
use HttpSoft\Basis\ErrorHandler\ErrorJsonResponseGenerator;
9
use HttpSoft\Basis\ErrorHandler\LogErrorListener;
10
use HttpSoft\ErrorHandler\ErrorHandlerMiddleware;
11
use Psr\Container\ContainerInterface;
12
use Psr\Log\LoggerInterface;
13
14
final class ErrorHandlerMiddlewareFactory implements FactoryInterface
15
{
16
    /**
17
     * @param ContainerInterface $container
18
     * @return ErrorHandlerMiddleware
19
     * @psalm-suppress MixedArgument
20
     * @psalm-suppress MixedArrayAccess
21
     */
22 4
    public function create(ContainerInterface $container): ErrorHandlerMiddleware
23
    {
24 4
        $errorHandler = new ErrorHandlerMiddleware(new ErrorJsonResponseGenerator($container->get('config')['debug']));
25 2
        $errorHandler->addListener(new LogErrorListener($container->get(LoggerInterface::class)));
26 2
        return $errorHandler;
27
    }
28
}
29