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

MonologServiceInitializer::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 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