Conditions | 1 |
Paths | 1 |
Total Lines | 20 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
31 | public function validate( |
||
32 | SchemaInterface $schema, |
||
33 | DocumentNode $document, |
||
34 | array $rules = [], |
||
35 | ?TypeInfo $typeInfo = null |
||
36 | ): array { |
||
37 | $typeInfo = $typeInfo ?? new TypeInfo($schema); |
||
38 | |||
39 | $context = $this->contextBuilder->build($schema, $document, $typeInfo); |
||
40 | |||
41 | $visitors = array_map(function (RuleInterface $rule) use ($context) { |
||
42 | return $rule->setValidationContext($context); |
||
43 | }, $rules ?? specifiedRules()); |
||
44 | |||
45 | $visitor = new TypeInfoVisitor($typeInfo, new ParallelVisitor($visitors)); |
||
46 | |||
47 | // Visit the whole document with each instance of all provided rules. |
||
48 | $document->acceptVisitor($visitor); |
||
49 | |||
50 | return $context->getErrors(); |
||
51 | } |
||
53 |