FromYearFilter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 60
rs 10
c 0
b 0
f 0
ccs 13
cts 13
cp 1
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 4 1
A __construct() 0 4 1
A getDescription() 0 3 1
A getName() 0 3 1
A getValue() 0 3 1
1
<?php
2
/**
3
 * File: FromYearFilter.php
4
 *
5
 * @author      Maciej Sławik <[email protected]>
6
 * Github:      https://github.com/maciejslawik
7
 */
8
9
namespace MSlwk\Otomoto\App\Stats\Filter;
10
11
use MSlwk\Otomoto\App\Exception\IncorrectFilterValueException;
12
use MSlwk\Otomoto\App\Stats\Filter\Validator\FilterValidatorInterface;
13
14
/**
15
 * Class FromYearFilter
16
 * @package MSlwk\Otomoto\App\Stats\Filter
17
 */
18
class FromYearFilter implements FilterInterface
19
{
20
    const FILTER_NAME = 'search[filter_float_year:from]';
21
    const FILTER_DESC = 'FROM year of production';
22
23
    /**
24
     * @var string
25
     */
26
    private $value;
27
28
    /**
29
     * @var FilterValidatorInterface
30
     */
31
    private $validator;
32
33
    /**
34
     * FromYearFilter constructor.
35
     * @param FilterValidatorInterface $validator
36
     * @param string $value
37
     * @throws IncorrectFilterValueException
38
     */
39 4
    public function __construct(FilterValidatorInterface $validator, string $value)
40
    {
41 4
        $this->validator = $validator;
42 4
        $this->setValue($value);
43 4
    }
44
45
    /**
46
     * @return string
47
     */
48 1
    public function getName(): string
49
    {
50 1
        return self::FILTER_NAME;
51
    }
52
53
    /**
54
     * @return string
55
     */
56 1
    public function getDescription(): string
57
    {
58 1
        return self::FILTER_DESC;
59
    }
60
61
    /**
62
     * @return string
63
     */
64 1
    public function getValue(): string
65
    {
66 1
        return $this->value;
67
    }
68
69
    /**
70
     * @param string $value
71
     * @return void
72
     * @throws IncorrectFilterValueException
73
     */
74 4
    public function setValue(string $value): void
75
    {
76 4
        $this->validator->validate($value);
77 4
        $this->value = $value;
78 4
    }
79
}
80