| Conditions | 4 |
| Paths | 6 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | 16 | public function apply($instance, stdClass $schema, Context $context, Walker $walker) |
|
| 33 | { |
||
| 34 | 16 | $accumulatingContext = $context->duplicate(); |
|
| 35 | 16 | $hasMatch = false; |
|
| 36 | |||
| 37 | 16 | foreach ($schema->anyOf as $subSchema) { |
|
| 38 | 16 | $originalCount = $accumulatingContext->countViolations(); |
|
| 39 | 16 | $walker->applyConstraints($instance, $subSchema, $accumulatingContext); |
|
| 40 | |||
| 41 | 16 | if ($accumulatingContext->countViolations() === $originalCount) { |
|
| 42 | 12 | $hasMatch = true; |
|
| 43 | 12 | break; |
|
| 44 | } |
||
| 45 | 16 | } |
|
| 46 | |||
| 47 | 16 | if (!$hasMatch) { |
|
| 48 | 4 | $context->mergeViolations($accumulatingContext); |
|
| 49 | 4 | $context->addViolation('instance must match at least one of the schemas listed in anyOf'); |
|
| 50 | 4 | } |
|
| 51 | 16 | } |
|
| 52 | } |
||
| 53 |