Passed
Pull Request — master (#57)
by Witold
07:04
created

MonologServiceInitializer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
A setMonologService() 0 6 2
1
<?php
2
/**
3
 * @author Evgeny Shpilevsky <[email protected]>
4
 */
5
6
namespace EnliteMonolog\Service;
7
8
use Interop\Container\ContainerInterface;
9
use Zend\ServiceManager\Initializer\InitializerInterface;
10
use Zend\ServiceManager\ServiceLocatorInterface;
11
12
final class MonologServiceInitializer implements InitializerInterface
13
{
14
    /**
15
     * @param mixed $instance
16
     */
17 5
    public function __invoke(ContainerInterface $container, $instance)
18
    {
19 5
        $this->setMonologService($container, $instance);
20 5
    }
21
22
    /**
23
     * @param ServiceLocatorInterface|ContainerInterface $container
24
     * @param mixed $instance
25
     */
26 5
    private function setMonologService($container, $instance): void
27
    {
28 5
        if ($instance instanceof MonologServiceAwareInterface) {
29 3
            $instance->setMonologService($container->get('EnliteMonologService'));
30
        }
31 5
    }
32
}
33