| 1 | <?php |
||
| 15 | trait ValidatorJitCache |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var ValidatorInterface[] |
||
| 19 | */ |
||
| 20 | private $validators; |
||
| 21 | |||
| 22 | 183 | public function isValidClearing(AccountNumber $account): bool |
|
| 23 | { |
||
| 24 | 183 | return $this->getValidators()[0]->validate($account)->isValid(); |
|
| 25 | } |
||
| 26 | |||
| 27 | 183 | public function validate(AccountNumber $account): ResultInterface |
|
| 28 | { |
||
| 29 | 183 | $results = []; |
|
| 30 | |||
| 31 | 183 | foreach ($this->getValidators() as $validator) { |
|
| 32 | 183 | $results[] = $validator->validate($account); |
|
| 33 | } |
||
| 34 | |||
| 35 | 183 | return new ResultCollection(...$results); |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Get clearing number validator |
||
| 40 | */ |
||
| 41 | abstract protected function getClearingValidator(): ValidatorInterface; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Get additional validators that definies format |
||
| 45 | * |
||
| 46 | * @return ValidatorInterface[] |
||
| 47 | */ |
||
| 48 | abstract protected function getAdditionalValidators(): array; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return ValidatorInterface[] |
||
| 52 | */ |
||
| 53 | 225 | private function getValidators(): array |
|
| 62 | } |
||
| 63 |