Passed
Push — master ( ce891b...aad205 )
by Timothy
42s
created

MonologServiceInitializer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 35
ccs 10
cts 10
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
A setMonologService() 0 6 2
A initialize() 0 4 1
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\InitializerInterface;
10
use Zend\ServiceManager\ServiceLocatorInterface;
11
12
class MonologServiceInitializer implements InitializerInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Zend\ServiceManager\InitializerInterface has been deprecated with message: Use Zend\ServiceManager\Initializer\InitializerInterface instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
13
{
14
15
    /**
16
     * Initialize
17
     *
18
     * @param $instance
19
     * @param ServiceLocatorInterface $serviceLocator
20
     * @return mixed
21
     */
22 2
    public function initialize($instance, ServiceLocatorInterface $serviceLocator)
23
    {
24 2
        $this->setMonologService($serviceLocator, $instance);
25 2
    }
26
27
    /**
28
     * @param ContainerInterface $container
29
     * @param $instance
30
     */
31 3
    public function __invoke(ContainerInterface $container, $instance)
32
    {
33 3
        $this->setMonologService($container, $instance);
34 3
    }
35
36
    /**
37
     * @param ServiceLocatorInterface|ContainerInterface $container
38
     * @param $instance
39
     */
40 5
    private function setMonologService($container, $instance)
41
    {
42 5
        if ($instance instanceof MonologServiceAwareInterface) {
43 3
            $instance->setMonologService($container->get('EnliteMonologService'));
44
        }
45 5
    }
46
}
47