Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
9 / 9 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
ValidatorMinMaxDate | |
100.00% |
9 / 9 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getValTester | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setValTester | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setMsgContent | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
testValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * @author: Doug Wilbourne (dougwilbourne@gmail.com) |
5 | */ |
6 | declare(strict_types=1); |
7 | |
8 | namespace pvc\validator\validator; |
9 | |
10 | use DateTime; |
11 | use pvc\interfaces\msg\MsgInterface; |
12 | use pvc\validator\val_tester\min_max\MinMaxDateTester; |
13 | use pvc\validator\Validator; |
14 | |
15 | /** |
16 | * Class ValidatorMinMaxDate |
17 | * @extends Validator<DateTime> |
18 | */ |
19 | class ValidatorMinMaxDate extends Validator |
20 | { |
21 | /** |
22 | * @var MinMaxDateTester |
23 | */ |
24 | protected MinMaxDateTester $valTester; |
25 | |
26 | /** |
27 | * @param MsgInterface $msg |
28 | * @param MinMaxDateTester $tester |
29 | */ |
30 | public function __construct(MsgInterface $msg, MinMaxDateTester $tester) |
31 | { |
32 | parent::__construct($msg); |
33 | $this->setValTester($tester); |
34 | } |
35 | |
36 | /** |
37 | * getValTester |
38 | * @return MinMaxDateTester |
39 | */ |
40 | public function getValTester(): MinMaxDateTester |
41 | { |
42 | return $this->valTester; |
43 | } |
44 | |
45 | /** |
46 | * setValTester |
47 | * @param MinMaxDateTester $tester |
48 | */ |
49 | public function setValTester(MinMaxDateTester $tester): void |
50 | { |
51 | $this->valTester = $tester; |
52 | } |
53 | |
54 | /** |
55 | * setMsgContent |
56 | */ |
57 | protected function setMsgContent(): void |
58 | { |
59 | $msgId = 'invalid_min_max_date'; |
60 | $msgParameters = ['min' => $this->valTester->getMin(), 'max' => $this->valTester->getMax()]; |
61 | $domain = 'Validator'; |
62 | $this->getMsg()->setContent($domain, $msgId, $msgParameters); |
63 | } |
64 | |
65 | /** |
66 | * testValue |
67 | * @param DateTime $data |
68 | * @return bool |
69 | */ |
70 | protected function testValue(mixed $data): bool |
71 | { |
72 | return $this->valTester->testValue($data); |
73 | } |
74 | } |