| Total Complexity | 5 | 
| Total Lines | 40 | 
| Duplicated Lines | 0 % | 
| Coverage | 100% | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 12 | class ExcludingValidatorChain implements Validator\ValidatorInterface | ||
| 13 | { | ||
| 14 | private array $validators; | ||
| 15 | private array $messages = []; | ||
| 16 | |||
| 17 | 7 | public function __construct(Validator\ValidatorInterface ...$validators) | |
| 18 |     { | ||
| 19 | 7 | $this->validators = $validators; | |
| 20 | } | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @param mixed $value | ||
| 24 | */ | ||
| 25 | 4 | public function isValid($value): bool | |
| 26 |     { | ||
| 27 | 4 | return some( | |
| 28 | 4 | $this->validators, | |
| 29 |             function (Validator\ValidatorInterface $validator) use ($value): bool { | ||
| 30 | 4 |                 if ($validator->isValid($value)) { | |
| 31 | 3 | return true; | |
| 32 | } | ||
| 33 | |||
| 34 | 3 | $messages = $validator->getMessages(); | |
| 35 | 3 | $this->messages = array_replace_recursive($this->messages, $messages); | |
| 36 | 3 | return false; | |
| 37 | 4 | }, | |
| 38 | ); | ||
| 39 | } | ||
| 40 | |||
| 41 | /** | ||
| 42 | * @param mixed $value | ||
| 43 | */ | ||
| 44 | 3 | public function __invoke($value): bool | |
| 45 |     { | ||
| 46 | 3 | return $this->isValid($value); | |
| 47 | } | ||
| 48 | |||
| 49 | 1 | public function getMessages(): array | |
| 52 | } | ||
| 53 | } | ||
| 54 |