EntityRepositoryManagerFactory   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 64.29%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 3
dl 41
loc 41
ccs 9
cts 14
cp 0.6429
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __invoke() 27 27 6
A createService() 10 10 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
 * Polder Knowledge / entityservice-module (https://polderknowledge.com)
4
 *
5
 * @link https://github.com/polderknowledge/entityservice-module for the canonical source repository
6
 * @copyright Copyright (c) 2016 Polder Knowledge (https://polderknowledge.com)
7
 * @license https://github.com/polderknowledge/entityservice-module/blob/master/LICENSE.md MIT
8
 */
9
10
namespace PolderKnowledge\EntityService\Repository\Service;
11
12
use Interop\Container\ContainerInterface;
13
use Zend\ServiceManager\Config;
14
use Zend\ServiceManager\FactoryInterface;
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
17 View Code Duplication
class EntityRepositoryManagerFactory implements FactoryInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Zend\ServiceManager\FactoryInterface has been deprecated with message: Use Zend\ServiceManager\Factory\FactoryInterface instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
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...
18
{
19 6
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
20
    {
21 6
        $options = $options ?: [];
22
23 6
        $pluginManager = new EntityRepositoryManager($container, $options);
24
25
        // If this is in a zend-mvc application, the ServiceListener will inject
26
        // merged configuration during bootstrap.
27 6
        if ($container->has('ServiceListener')) {
28 3
            return $pluginManager;
29
        }
30
31
        // If we do not have a config service, nothing more to do
32 3
        if (!$container->has('config')) {
33 3
            return $pluginManager;
34
        }
35
36
        $config = $container->get('config');
37
        // If we do not have log_filters configuration, nothing more to do
38
        if (!isset($config['entity_repository_manager']) || !is_array($config['entity_repository_manager'])) {
39
            return $pluginManager;
40
        }
41
        // Wire service configuration for log_filters
42
        (new Config($config['entity_repository_manager']))->configureServiceManager($pluginManager);
43
44
        return $pluginManager;
45
    }
46
47 3
    public function createService(ServiceLocatorInterface $serviceLocator)
48
    {
49
        // @codeCoverageIgnoreStart
50
        if (method_exists($serviceLocator, 'getServiceLocator')) {
51
            $serviceLocator = $serviceLocator->getServiceLocator();
52
        }
53
        // @codeCoverageIgnoreEnd
54
55 3
        return $this($serviceLocator, '');
56
    }
57
}
58