| Total Complexity | 6 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Coverage | 66.67% |
| Changes | 0 | ||
| 1 | <?php |
||
| 39 | trait Validator |
||
| 40 | { |
||
| 41 | /** |
||
| 42 | * @var ValidatorForm instance |
||
| 43 | */ |
||
| 44 | private $validatorForm; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Get ValidatorBuilder |
||
| 48 | * |
||
| 49 | * @return ValidatorForm |
||
| 50 | */ |
||
| 51 | 2 | private function getValidatorForm(): ValidatorForm |
|
| 52 | { |
||
| 53 | 2 | if (!$this->validatorForm) { |
|
| 54 | 2 | $this->validatorForm = new ValidatorForm(); |
|
| 55 | } |
||
| 56 | 2 | return $this->validatorForm; |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Add ValidatorChain |
||
| 61 | * |
||
| 62 | * @param string $name |
||
| 63 | * |
||
| 64 | * @return ValidatorChain |
||
| 65 | */ |
||
| 66 | 2 | public function addValidator($name): ValidatorChain |
|
| 67 | { |
||
| 68 | 2 | return $this->getValidatorForm()->add($name); |
|
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Get ValidatorChain |
||
| 73 | * |
||
| 74 | * @param string $name |
||
| 75 | * |
||
| 76 | * @return ValidatorChain |
||
| 77 | */ |
||
| 78 | public function getValidator($name): ValidatorChain |
||
| 79 | { |
||
| 80 | return $this->getValidatorForm()->get($name); |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Validate input data |
||
| 85 | * |
||
| 86 | * @param array $input |
||
| 87 | * |
||
| 88 | * @return bool |
||
| 89 | */ |
||
| 90 | public function validate($input): bool |
||
| 91 | { |
||
| 92 | return $this->getValidatorForm()->validate($input); |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Assert input data |
||
| 97 | * |
||
| 98 | * @param array $input |
||
| 99 | * |
||
| 100 | * @throws \Bluz\Validator\Exception\ValidatorException |
||
| 101 | */ |
||
| 102 | 2 | public function assert($input): void |
|
| 105 | 2 | } |
|
| 106 | } |
||
| 107 |