ServiceManagerAwareTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setServiceManager() 0 9 2
A getServiceManager() 0 4 1
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine
4
 * @year 2016
5
 * @author Lobanov Aleksandr <[email protected]>
6
 */
7
8
namespace Nnx\Doctrine\Traits\Factory;
9
10
use Zend\ServiceManager\AbstractPluginManager;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
use Zend\ServiceManager\ServiceManager;
13
14
/**
15
 * Class ServiceManagerAwareTrait
16
 * @package Nnx\Doctrine\Traits\Factory
17
 */
18
trait ServiceManagerAwareTrait
19
{
20
    /**
21
     * @var ServiceManager
22
     */
23
    private $serviceManager;
24
25
    /**
26
     * @param ServiceLocatorInterface $serviceLocator
27
     */
28
    public function setServiceManager(ServiceLocatorInterface $serviceLocator)
29
    {
30
        /** @var \Zend\ServiceManager\ServiceManager $serviceManager */
31
        $serviceManager = ($serviceLocator instanceof AbstractPluginManager)
32
            ? $serviceLocator->getServiceLocator()
33
            : $serviceLocator;
34
35
        $this->serviceManager = $serviceManager;
36
    }
37
38
    /**
39
     * @return \Zend\ServiceManager\ServiceManager
40
     */
41
    public function getServiceManager()
42
    {
43
        return $this->serviceManager;
44
    }
45
}
46