Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ParserBooleanOneZero | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| parseValue | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |||
| setMsgContent | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @author: Doug Wilbourne (dougwilbourne@gmail.com) |
| 4 | */ |
| 5 | |
| 6 | declare(strict_types=1); |
| 7 | |
| 8 | namespace pvc\parser\boolean; |
| 9 | |
| 10 | use pvc\interfaces\msg\MsgInterface; |
| 11 | use pvc\parser\Parser; |
| 12 | |
| 13 | /** |
| 14 | * Input must be either a 1 or a 0 to parse correctly. |
| 15 | * |
| 16 | * Class ParserBooleanOneZero |
| 17 | * @extends Parser<bool> |
| 18 | */ |
| 19 | class ParserBooleanOneZero extends Parser |
| 20 | { |
| 21 | /** |
| 22 | * @function parseValue |
| 23 | * @param string $data |
| 24 | * @return bool |
| 25 | */ |
| 26 | protected function parseValue(string $data): bool |
| 27 | { |
| 28 | if ($data == '1') { |
| 29 | $this->parsedValue = true; |
| 30 | return true; |
| 31 | } |
| 32 | if ($data == '0') { |
| 33 | $this->parsedValue = false; |
| 34 | return true; |
| 35 | } |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * setMsgContent |
| 41 | * @param MsgInterface $msg |
| 42 | */ |
| 43 | protected function setMsgContent(MsgInterface $msg): void |
| 44 | { |
| 45 | $msgId = 'not_boolean_one_zero'; |
| 46 | $msgParameters = []; |
| 47 | $msg->setContent($this->getMsgDomain(), $msgId, $msgParameters); |
| 48 | } |
| 49 | } |