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

ConnectionRegistryEventSubscriberFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

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 23
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 11 11 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 ConnectionRegistryEventSubscriberFactory
16
 *
17
 * @package Nnx\DoctrineFixtureModule\FixtureInitializer
18
 */
19 View Code Duplication
class ConnectionRegistryEventSubscriberFactory
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
     * @param ServiceLocatorInterface $serviceLocator
25
     *
26
     * @return ConnectionRegistryEventSubscriber|mixed
27
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
28
     * @throws \Nnx\DoctrineFixtureModule\Utils\Exception\RuntimeException
29
     */
30
    public function createService(ServiceLocatorInterface $serviceLocator)
31
    {
32
        $appServiceLocator = $serviceLocator instanceof AbstractPluginManager ?  $serviceLocator->getServiceLocator() : $serviceLocator;
33
34
35
        /** @var ManagerRegistryProviderInterface $managerRegistryProvider */
36
        $managerRegistryProvider = $appServiceLocator->get(ManagerRegistryProviderInterface::class);
37
        $managerRegistry = $managerRegistryProvider->getManagerRegistry();
38
39
        return new ConnectionRegistryEventSubscriber($managerRegistry);
40
    }
41
}
42