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