ClassListFixtureExecutorFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B createService() 0 41 3
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine-fixture-module
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\DoctrineFixtureModule\Executor;
7
8
use Nnx\DoctrineFixtureModule\FixtureInitializer\FixtureInitializerManagerInterface;
9
use Nnx\ModuleOptions\ModuleOptionsPluginManagerInterface;
10
use Zend\ServiceManager\AbstractPluginManager;
11
use Zend\ServiceManager\FactoryInterface;
12
use Zend\ServiceManager\MutableCreationOptionsInterface;
13
use Zend\ServiceManager\MutableCreationOptionsTrait;
14
use Zend\ServiceManager\ServiceLocatorInterface;
15
use Nnx\DoctrineFixtureModule\Loader\FixtureLoaderManagerInterface;
16
use Nnx\DoctrineFixtureModule\Options\ModuleOptions;
17
use Doctrine\Fixture\Loader\ClassLoader;
18
19
20
21
/**
22
 * Class ClassListFixtureExecutorFactory
23
 *
24
 * @package Nnx\DoctrineFixtureModule\Executor
25
 */
26
class ClassListFixtureExecutorFactory implements FactoryInterface, MutableCreationOptionsInterface
27
{
28
    use MutableCreationOptionsTrait;
29
30
    /**
31
     * @inheritDoc
32
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
33
     */
34
    public function createService(ServiceLocatorInterface $serviceLocator)
35
    {
36
        $appServiceLocator = $serviceLocator instanceof AbstractPluginManager ? $serviceLocator->getServiceLocator() :$serviceLocator;
37
38
        $creationOptions = $this->getCreationOptions();
39
40
        /** @var DefaultExecutorConfiguration $configuration */
41
        $configuration = $appServiceLocator->get(DefaultExecutorConfiguration::class);
42
        /** @var FixtureExecutorBuilderInterface $builder */
43
        $builder = $appServiceLocator->get(FixtureExecutorBuilderInterface::class);
44
45
       /** @var FixtureInitializerManagerInterface $fixtureInitializerManager */
46
        $fixtureInitializerManager = $appServiceLocator->get(FixtureInitializerManagerInterface::class);
47
48
        $executor = new ClassListFixtureExecutor($configuration, $builder, $fixtureInitializerManager);
49
50
51
        /** @var FixtureLoaderManagerInterface $fixtureLoaderManager */
52
        $fixtureLoaderManager = $appServiceLocator->get(FixtureLoaderManagerInterface::class);
53
54
        $classList = array_key_exists('classList', $creationOptions) ? $creationOptions['classList'] : [];
55
56
        $classLoaderCreationOptions = [
57
            'classList' => $classList
58
        ];
59
        $loader = $fixtureLoaderManager->get(ClassLoader::class, $classLoaderCreationOptions);
0 ignored issues
show
Unused Code introduced by
The call to FixtureLoaderManagerInterface::get() has too many arguments starting with $classLoaderCreationOptions.

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...
60
        $executor->setLoader($loader);
61
62
63
64
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */
65
        $moduleOptionsPluginManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class);
66
67
        /** @var ModuleOptions $moduleOptions */
68
        $moduleOptions = $moduleOptionsPluginManager->get(ModuleOptions::class);
69
70
        $executor->setContextInitializer($moduleOptions->getContextInitializer());
71
72
73
        return $executor;
74
    }
75
}
76