ErrorHandlerManagerFactory::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Acelaya\ExpressiveErrorHandler\ErrorHandler\Factory;
6
7
use Acelaya\ExpressiveErrorHandler\ErrorHandler\ErrorResponseGeneratorManager;
8
use Interop\Container\ContainerInterface;
9
use Interop\Container\Exception\ContainerException;
10
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
11
use Zend\ServiceManager\Exception\ServiceNotFoundException;
12
13
class ErrorHandlerManagerFactory
14
{
15
    /**
16
     * Create an object
17
     *
18
     * @param  ContainerInterface $container
19
     * @return object
20
     * @throws ServiceNotFoundException if unable to resolve the service.
21
     * @throws ServiceNotCreatedException if an exception is raised when
22
     *     creating a service.
23
     * @throws ContainerException if any other error occurs
24
     */
25 1
    public function __invoke(ContainerInterface $container)
26
    {
27 1
        $config = $container->has('config') ? $container->get('config') : [];
28 1
        $plugins = $config['error_handler']['plugins'] ?? [];
29 1
        return new ErrorResponseGeneratorManager($container, $plugins);
30
    }
31
}
32