Completed
Push — dev ( 14e4a6...854686 )
by Андрей
02:59
created

createService()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 11
loc 11
rs 9.4285
cc 2
eloc 5
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\FixtureInitializer;
7
8
use Nnx\DoctrineFixtureModule\Utils\ManagerRegistryProviderInterface;
9
use Zend\ServiceManager\AbstractPluginManager;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
13
14
/**
15
 * Class ManagerRegistryEventSubscriberFactory
16
 *
17
 * @package Nnx\DoctrineFixtureModule\FixtureInitializer
18
 */
19 View Code Duplication
class ManagerRegistryEventSubscriberFactory
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
    implements FactoryInterface
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
21
{
22
23
24
    /**
25
     * @param ServiceLocatorInterface $serviceLocator
26
     *
27
     * @return ManagerRegistryEventSubscriber|mixed
28
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
29
     * @throws \Nnx\DoctrineFixtureModule\Utils\Exception\RuntimeException
30
     */
31
    public function createService(ServiceLocatorInterface $serviceLocator)
32
    {
33
        $appServiceLocator = $serviceLocator instanceof AbstractPluginManager ?  $serviceLocator->getServiceLocator() : $serviceLocator;
34
35
        /** @var ManagerRegistryProviderInterface $managerRegistryProvider */
36
        $managerRegistryProvider = $appServiceLocator->get(ManagerRegistryProviderInterface::class);
37
        $managerRegistry = $managerRegistryProvider->getManagerRegistry();
38
39
40
        return new ManagerRegistryEventSubscriber($managerRegistry);
41
    }
42
}
43