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