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

MonologServiceInitializer::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
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\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