ExecutorControllerFactory::createService()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 6
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 Zend\ServiceManager\AbstractPluginManager;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
13
/**
14
 * Class ExecutorControllerFactory
15
 *
16
 * @package Nnx\DoctrineFixtureModule\Entity
17
 */
18
class ExecutorControllerFactory implements FactoryInterface
19
{
20
    /**
21
     * @inheritDoc
22
     *
23
     * @return ExecutorController
24
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
25
     */
26
    public function createService(ServiceLocatorInterface $serviceLocator)
27
    {
28
        $appServiceLocator = $serviceLocator;
29
        if ($serviceLocator instanceof AbstractPluginManager) {
30
            $appServiceLocator = $serviceLocator->getServiceLocator();
31
        }
32
33
        /** @var FixtureExecutorManagerInterface $fixtureExecutorManager */
34
        $fixtureExecutorManager = $appServiceLocator->get(FixtureExecutorManagerInterface::class);
35
36
37
        return new ExecutorController($fixtureExecutorManager);
38
    }
39
}
40