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

ExactMatch   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A accept() 0 8 2
A getValue() 0 4 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