Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| IsValidatable | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| addValidators | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| validators | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Field\Capability; |
| 6 | |
| 7 | trait IsValidatable |
| 8 | { |
| 9 | protected array $validators = []; |
| 10 | |
| 11 | public function addValidators(string ...$validators): static |
| 12 | { |
| 13 | $this->validators = array_merge($this->validators, $validators); |
| 14 | |
| 15 | return $this; |
| 16 | } |
| 17 | |
| 18 | public function validators(): array |
| 19 | { |
| 20 | return array_values(array_unique($this->validators)); |
| 21 | } |
| 22 | } |