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