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

PrefixMatch::getPrefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Everlution\Navigation\Voter\Prefix;
6
7
use Everlution\Navigation\Property\BaseProperty;
8
use Everlution\Navigation\Voter\Match;
9
use Everlution\Navigation\Voter\Voter;
10
11
/**
12
 * Class PrefixMatch.
13
 * @author Ivan Barlog <[email protected]>
14
 */
15
class PrefixMatch extends BaseProperty implements Match
16
{
17
    /** @var string */
18
    private $prefix;
19
20
    public function __construct(string $prefix)
21
    {
22
        $this->prefix = $prefix;
23
    }
24
25
    /**
26
     * @param Voter $voter
27
     * @return null|string
28
     */
29
    public function accept(Voter &$voter)
30
    {
31
        if (!$voter instanceof PrefixVoter) {
32
            return null;
33
        }
34
35
        return $this->prefix;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getPrefix(): string
42
    {
43
        return $this->prefix;
44
    }
45
}
46