Completed
Push — dev ( 854686...1d55ed )
by Андрей
04:48
created

ExecutorControllerFactory::createService()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 14
Ratio 100 %
Metric Value
dl 14
loc 14
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine-fixture-module
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\DoctrineFixtureModule\Controller;
7
8
use Nnx\DoctrineFixtureModule\Executor\FixtureExecutorManagerInterface;
9
use Nnx\DoctrineFixtureModule\Utils\ManagerRegistryProviderInterface;
10
use Zend\ServiceManager\AbstractPluginManager;
11
use Zend\ServiceManager\FactoryInterface;
12
use Zend\ServiceManager\ServiceLocatorInterface;
13
14
/**
15
 * Class ExecutorControllerFactory
16
 *
17
 * @package Nnx\DoctrineFixtureModule\Entity
18
 */
19 View Code Duplication
class ExecutorControllerFactory implements FactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    /**
22
     * @inheritDoc
23
     *
24
     * @return ExecutorController
25
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
26
     */
27
    public function createService(ServiceLocatorInterface $serviceLocator)
28
    {
29
        $appServiceLocator = $serviceLocator;
30
        if ($serviceLocator instanceof AbstractPluginManager) {
31
            $appServiceLocator = $serviceLocator->getServiceLocator();
32
        }
33
        /** @var ManagerRegistryProviderInterface $managerRegistryProvider */
34
        $managerRegistryProvider = $appServiceLocator->get(ManagerRegistryProviderInterface::class);
35
        /** @var FixtureExecutorManagerInterface $fixtureExecutorManager */
36
        $fixtureExecutorManager = $appServiceLocator->get(FixtureExecutorManagerInterface::class);
37
38
39
        return new ExecutorController($managerRegistryProvider, $fixtureExecutorManager);
40
    }
41
}
42