Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Truthful | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
validate | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
getInverseError | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace Verja\Validator; |
4 | |
5 | use Verja\Error; |
6 | use Verja\Validator; |
7 | |
8 | class Truthful extends Validator |
9 | { |
10 | /** |
11 | * Validate $value |
12 | * |
13 | * @param mixed $value |
14 | * @param array $context |
15 | * @return bool |
16 | */ |
17 | public function validate($value, array $context = []): bool |
18 | { |
19 | if (!$value) { |
20 | $this->error = new Error('NOT_TRUTHFUL', $value, 'value should be truthful'); |
21 | return false; |
22 | } |
23 | |
24 | return true; |
25 | } |
26 | |
27 | public function getInverseError($value) |
28 | { |
29 | return new Error('IS_TRUTHFUL', $value, 'value should not be truthful'); |
30 | } |
31 | } |