Completed
Push — dev ( d8e2c0...b30194 )
by Андрей
02:16
created

DefaultEntryNameResolverFactory   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 18 2
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/container
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\Container;
7
8
use Zend\ServiceManager\AbstractPluginManager;
9
use Zend\ServiceManager\FactoryInterface;
10
use Zend\ServiceManager\ServiceLocatorInterface;
11
use Nnx\Container\EntryNameResolver\EntryNameResolverChain;
12
use Nnx\ModuleOptions\ModuleOptionsPluginManagerInterface;
13
use Nnx\Container\Options\ModuleOptions;
14
15
/**
16
 * Class DefaultEntryNameResolverFactory
17
 *
18
 * @package Nnx\Container
19
 */
20
class DefaultEntryNameResolverFactory implements FactoryInterface
21
{
22
    /**
23
     * @param ServiceLocatorInterface $serviceLocator
24
     *
25
     * @return DefaultEntryNameResolverInterface
26
     *
27
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
28
     */
29
    public function createService(ServiceLocatorInterface $serviceLocator)
30
    {
31
        $appServiceLocator = $serviceLocator;
32
        if ($serviceLocator instanceof AbstractPluginManager) {
33
            $appServiceLocator = $serviceLocator->getServiceLocator();
34
        }
35
36
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */
37
        $moduleOptionsPluginManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class);
38
39
        /** @var ModuleOptions $moduleOptions */
40
        $moduleOptions = $moduleOptionsPluginManager->get(ModuleOptions::class);
41
        $entryNameResolversConfig = $moduleOptions->getEntryNameResolvers();
42
43
        $entryNameResolverChain = $serviceLocator->get(EntryNameResolverChain::class, $entryNameResolversConfig);
0 ignored issues
show
Unused Code introduced by
The call to ServiceLocatorInterface::get() has too many arguments starting with $entryNameResolversConfig.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
Bug Compatibility introduced by
The expression $serviceLocator->get(\Nn...ryNameResolversConfig); of type object|array adds the type array to the return on line 45 which is incompatible with the return type documented by Nnx\Container\DefaultEnt...rFactory::createService of type Nnx\Container\DefaultEntryNameResolverInterface.
Loading history...
44
45
        return $entryNameResolverChain;
46
    }
47
}
48