FixtureInitializerManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 38
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A validatePlugin() 12 12 3

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 Zend\ServiceManager\AbstractPluginManager;
9
use Zend\ServiceManager\ConfigInterface;
10
11
/**
12
 * Class FixtureInitializerManager
13
 *
14
 * @package Nnx\DoctrineFixtureModule\FixtureInitializer
15
 */
16 View Code Duplication
class FixtureInitializerManager extends AbstractPluginManager implements FixtureInitializerManagerInterface
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...
17
{
18
    /**
19
     * Имя секции в конфиги приложения отвечающей за настройки менеджера
20
     *
21
     * @var string
22
     */
23
    const CONFIG_KEY = 'nnx_fixture_initializer';
24
25
    /**
26
     * @inheritDoc
27
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
28
     * @throws \Zend\ServiceManager\Exception\RuntimeException
29
     */
30
    public function __construct(ConfigInterface $configuration = null)
31
    {
32
        parent::__construct($configuration);
33
        $this->setShareByDefault(false);
34
    }
35
36
    /**
37
     * {@inheritDoc}
38
     *
39
     * @throws Exception\RuntimeException
40
     */
41
    public function validatePlugin($plugin)
42
    {
43
        if ($plugin instanceof FixtureInitializerInterface) {
44
            return;
45
        }
46
47
        throw new Exception\RuntimeException(sprintf(
48
            'Plugin of type %s is invalid; must implement %s',
49
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
50
            FixtureInitializerInterface::class
51
        ));
52
    }
53
}
54