| Conditions | 5 |
| Paths | 7 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 7 | protected function execute($value): ValidationResultInterface |
|
| 17 | { |
||
| 18 | 7 | $result = parent::execute($value); |
|
| 19 | 6 | if ($result->preventNextChecks()) { |
|
| 20 | 1 | return $result; |
|
| 21 | } |
||
| 22 | |||
| 23 | 6 | $result = new ValidationSuccessResult(false); |
|
| 24 | |||
| 25 | 6 | $errors = []; |
|
| 26 | 6 | foreach ($this->rules as $rule) { |
|
| 27 | try { |
||
| 28 | 5 | $rule->validate($value); |
|
| 29 | 3 | } catch (ValidationError $e) { |
|
| 30 | 3 | $errors[] = $e; |
|
| 31 | 3 | break; |
|
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | 6 | if (\count($errors) === 0) { |
|
| 36 | 3 | return $result; |
|
| 37 | } |
||
| 38 | |||
| 39 | 3 | throw ValidationError::fromValidationErrors($this->name, $value, $errors); |
|
| 40 | } |
||
| 42 |