NullEventManagerFactory::createService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Abacaphiliac\Zend\EventManager\PluginManager;
4
5
use Zend\EventManager\SharedEventManager;
6
use Zend\EventManager\SharedEventManagerInterface;
7
use Zend\ServiceManager\FactoryInterface;
8
use Zend\ServiceManager\ServiceLocatorInterface;
9
10
class NullEventManagerFactory implements FactoryInterface
11
{
12
    /**
13
     * @param ServiceLocatorInterface $serviceLocator
14
     * @return \Zend\EventManager\EventManager
15
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
16
     */
17 2
    public function createService(ServiceLocatorInterface $serviceLocator)
18
    {
19 2
        $sharedEventManager = $this->getSharedEventManager($serviceLocator);
20
        
21 2
        return new NullEventManager($sharedEventManager);
22
    }
23
24
    /**
25
     * @param ServiceLocatorInterface $serviceLocator
26
     * @return SharedEventManagerInterface
27
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
28
     */
29 2
    private function getSharedEventManager(ServiceLocatorInterface $serviceLocator)
30
    {
31 2
        if ($serviceLocator->has('SharedEventManager')) {
32 1
            return $serviceLocator->get('SharedEventManager');
0 ignored issues
show
Bug Compatibility introduced by
The expression $serviceLocator->get('SharedEventManager'); of type object|array adds the type array to the return on line 32 which is incompatible with the return type documented by Abacaphiliac\Zend\EventM...::getSharedEventManager of type Zend\EventManager\SharedEventManagerInterface.
Loading history...
33
        }
34
        
35 1
        return new SharedEventManager();
36
    }
37
}
38