Completed
Push — master ( 5f7cbd...b12d8e )
by Alejandro
03:03
created

ErrorHandlerManagerFactory::__invoke()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

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