Completed
Push — master ( 843e94...46dd70 )
by Андрей
6s
created

ResolverByClassNameFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 14 2
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/entry-name-resolver
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\EntryNameResolver;
7
8
use Nnx\ModuleOptions\ModuleOptionsPluginManagerInterface;
9
use Zend\ServiceManager\AbstractPluginManager;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\MutableCreationOptionsInterface;
12
use Zend\ServiceManager\ServiceLocatorInterface;
13
use Zend\ServiceManager\MutableCreationOptionsTrait;
14
15
/**
16
 * Class ResolverByClassNameFactory
17
 *
18
 * @package Nnx\EntryNameResolver
19
 */
20
class ResolverByClassNameFactory implements FactoryInterface, MutableCreationOptionsInterface
21
{
22
    use MutableCreationOptionsTrait;
23
24
    /**
25
     * @inheritdoc
26
     *
27
     * @param ServiceLocatorInterface $serviceLocator
28
     *
29
     * @return ResolverByModuleContextMap
30
     *
31
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
32
     */
33
    public function createService(ServiceLocatorInterface $serviceLocator)
34
    {
35
        $appServiceLocator = $serviceLocator;
36
        if ($serviceLocator instanceof AbstractPluginManager) {
37
            $appServiceLocator = $serviceLocator->getServiceLocator();
38
        }
39
40
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */
41
        $moduleOptionsPluginManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class);
42
43
        $resolverByModuleContextMap = new ResolverByClassName($moduleOptionsPluginManager);
44
45
        return $resolverByModuleContextMap;
46
    }
47
}
48