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

ContentBasedErrorHandlerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 2
c 4
b 0
f 1
lcom 0
cbo 3
dl 0
loc 21
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 2
1
<?php
2
namespace Acelaya\ExpressiveErrorHandler\ErrorHandler\Factory;
3
4
use Acelaya\ExpressiveErrorHandler\ErrorHandler\ContentBasedErrorHandler;
5
use Acelaya\ExpressiveErrorHandler\ErrorHandler\ErrorHandlerManager;
6
use Acelaya\ExpressiveErrorHandler\Log\LogMessageBuilderInterface;
7
use Interop\Container\ContainerInterface;
8
use Interop\Container\Exception\ContainerException;
9
use Psr\Log\LoggerInterface;
10
use Psr\Log\NullLogger;
11
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
12
use Zend\ServiceManager\Exception\ServiceNotFoundException;
13
14
class ContentBasedErrorHandlerFactory
15
{
16
    /**
17
     * Create an object
18
     *
19
     * @param  ContainerInterface $container
20
     * @return object
21
     * @throws ServiceNotFoundException if unable to resolve the service.
22
     * @throws ServiceNotCreatedException if an exception is raised when
23
     *     creating a service.
24
     * @throws ContainerException if any other error occurs
25
     */
26 1
    public function __invoke(ContainerInterface $container)
27
    {
28 1
        $errorHandlerManager = $container->get(ErrorHandlerManager::class);
29 1
        $logger = $container->has(LoggerInterface::class) ? $container->get(LoggerInterface::class) : new NullLogger();
30 1
        $logMessageBuilder = $container->get(LogMessageBuilderInterface::class);
31
32 1
        return new ContentBasedErrorHandler($errorHandlerManager, $logger, $logMessageBuilder);
33
    }
34
}
35