Test Failed
Push — master ( 3eb0e4...9196b6 )
by Ivan
02:13
created

PrefixConfig   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 34
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getObject() 4 4 1
A getArray() 7 7 1
A config() 7 7 1

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
declare(strict_types = 1);
4
5
namespace Everlution\Navigation\Factory\Build\Hydrator\Match;
6
7
use Everlution\Navigation\Voter\Prefix\PrefixMatch;
8
9
/**
10
 * Class PrefixConfig.
11
 * @author Ivan Barlog <[email protected]>
12
 */
13 View Code Duplication
class PrefixConfig extends MatchConfig
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...
14
{
15
    const OPTION_PREFIX = 'prefix';
16
17
    /**
18
     * @param string $className
19
     * @param array $arguments
20
     * @return PrefixMatch
21
     */
22
    protected function getObject(string $className, array $arguments)
23
    {
24
        return new $className($arguments[self::OPTION_PREFIX]);
25
    }
26
27
    /**
28
     * @param PrefixMatch $item
29
     * @return array
30
     */
31
    protected function getArray($item): array
32
    {
33
        return [
34
            self::OPTION_CLASS => get_class($item),
35
            self::OPTION_PREFIX => $item->getPrefix(),
36
        ];
37
    }
38
39
    protected function config()
40
    {
41
        $this->resolver->setRequired(self::OPTION_PREFIX);
42
        $this->resolver->setAllowedTypes(self::OPTION_PREFIX, 'string');
43
44
        $this->supportedClasses[] = PrefixMatch::class;
45
    }
46
}
47