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

ExactMatch::accept()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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