Total Complexity | 9 |
Total Lines | 81 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
19 | class RangeValidator implements ValidatorInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $availableValues; |
||
25 | /** |
||
26 | * @var bool |
||
27 | */ |
||
28 | private $validateKeys; |
||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $errors; |
||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | private $validData; |
||
37 | |||
38 | /** |
||
39 | * RangeValidator constructor. |
||
40 | * |
||
41 | * @param array $options |
||
42 | */ |
||
43 | public function __construct(array $options = []) |
||
44 | 3 | { |
|
45 | $this->setOptions($options); |
||
46 | 3 | } |
|
47 | 3 | ||
48 | 3 | /** |
|
49 | * Set validator options. |
||
50 | * |
||
51 | * @param array $options |
||
52 | */ |
||
53 | public function setOptions(array $options) : void |
||
54 | { |
||
55 | $this->availableValues = isset($options['availableValues']) && is_array($options['availableValues']) |
||
56 | 2 | ? array_values($options['availableValues']) |
|
57 | : []; |
||
58 | 2 | $this->validateKeys = (bool) ($options['validateKeys'] ?? false); |
|
59 | 2 | } |
|
60 | |||
61 | 2 | /** |
|
62 | 2 | * Validates data. |
|
63 | 2 | * |
|
64 | * @param array $values |
||
65 | * @return bool |
||
66 | 2 | */ |
|
67 | public function validate(array $values) : bool |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Retrieve valid data. |
||
84 | * |
||
85 | * @return array |
||
86 | 2 | */ |
|
87 | public function getValidData() : array |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Gets errors from validation. |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | public function getErrors() : array |
||
102 |