| Total Complexity | 5 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | class Required implements RuleValidateInterface |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var array Rule properties |
||
| 22 | */ |
||
| 23 | public static $config = [ |
||
| 24 | 'class' => 'Required', |
||
| 25 | 'full_class' => __CLASS__, |
||
| 26 | 'alias' => ['required', 'req', 'rq'], |
||
| 27 | 'args_count' => 0, |
||
| 28 | 'args_type' => [], |
||
| 29 | 'has_validate' => true, |
||
| 30 | //'has_sanitize' => false |
||
| 31 | ]; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var string Error message |
||
| 35 | */ |
||
| 36 | private $message = ''; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Validate. |
||
| 40 | * |
||
| 41 | * @return bool |
||
| 42 | */ |
||
| 43 | 17 | public function validate(): bool |
|
| 44 | { |
||
| 45 | 17 | $args = func_get_args(); |
|
| 46 | |||
| 47 | 17 | return $this->concreteValidate($args[0]); |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Concrete validate. |
||
| 52 | * |
||
| 53 | * @param mixed $received |
||
| 54 | * |
||
| 55 | * @return bool |
||
| 56 | */ |
||
| 57 | 17 | private function concreteValidate($received): bool |
|
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Return error message. |
||
| 74 | * |
||
| 75 | * @return string Error message |
||
| 76 | */ |
||
| 77 | 3 | public function getMessage(): string |
|
| 82 |