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

PrefixConfig::getArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
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