| Total Complexity | 3 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class Number extends AbstractNumber implements RuleSanitizeInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var array Arguments expected. |
||
| 21 | */ |
||
| 22 | private $arguments = []; |
||
|
|
|||
| 23 | |||
| 24 | /** |
||
| 25 | * @var string Error message |
||
| 26 | */ |
||
| 27 | private $message = ''; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Validate. |
||
| 31 | * |
||
| 32 | * @param int|float $received |
||
| 33 | * |
||
| 34 | * @return bool |
||
| 35 | */ |
||
| 36 | 19 | public function validate($received): bool |
|
| 37 | { |
||
| 38 | 19 | if (!is_numeric($received)) { |
|
| 39 | 9 | $this->message = "Received value is not a number"; |
|
| 40 | 9 | return true; |
|
| 41 | } |
||
| 42 | |||
| 43 | 10 | return false; |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Return error message. |
||
| 48 | * |
||
| 49 | * @return string Error message |
||
| 50 | */ |
||
| 51 | 1 | public function getMessage(): string |
|
| 54 | } |
||
| 55 | } |
||
| 56 |