NullEventManagerFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createService() 0 6 1
A getSharedEventManager() 0 8 2
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