ErrorHandlerMiddlewareFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * This file is part of coisa/error-handler.
5
 *
6
 * (c) Felipe Sayão Lobato Abreu <[email protected]>
7
 *
8
 * This source file is subject to the license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
declare(strict_types=1);
13
14
namespace CoiSA\ErrorHandler\Container\Factory;
15
16
use CoiSA\ErrorHandler\ErrorHandler;
17
use CoiSA\ErrorHandler\Http\Message\ThrowableResponseFactoryInterface;
18
use CoiSA\ErrorHandler\Http\Middleware\ErrorHandlerMiddleware;
19
use Psr\Container\ContainerInterface;
20
21
/**
22
 * Class ErrorHandlerMiddlewareFactory
23
 *
24
 * @package CoiSA\ErrorHandler\Container\Factory
25
 */
26
final class ErrorHandlerMiddlewareFactory
27
{
28
    /**
29
     * @param ContainerInterface $container
30
     *
31
     * @return ErrorHandlerMiddleware
32
     */
33 5
    public function __invoke(ContainerInterface $container): ErrorHandlerMiddleware
34
    {
35 5
        $errorHandler             = $container->get(ErrorHandler::class);
36 5
        $throwableResponseFactory = $container->get(ThrowableResponseFactoryInterface::class);
37
38 5
        return new ErrorHandlerMiddleware($errorHandler, $throwableResponseFactory);
39
    }
40
}
41