| Total Complexity | 5 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class SchemaValidator implements SchemaValidatorInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @param SchemaInterface $schema |
||
| 14 | * @param RuleInterface[]|null $rules |
||
| 15 | * @return SchemaValidationException[] |
||
| 16 | */ |
||
| 17 | public function validate(SchemaInterface $schema, ?array $rules = null): array |
||
| 18 | { |
||
| 19 | $context = $this->createContext($schema); |
||
| 20 | |||
| 21 | $rules = $rules ?? SupportedRules::build(); |
||
| 22 | |||
| 23 | foreach ($rules as $rule) { |
||
| 24 | $rule->setContext($context)->evaluate(); |
||
| 25 | } |
||
| 26 | |||
| 27 | return $context->getErrors(); |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param SchemaInterface $schema |
||
| 32 | * @throws SchemaValidationException |
||
| 33 | */ |
||
| 34 | public function assertValid(SchemaInterface $schema): void |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @inheritdoc |
||
| 49 | */ |
||
| 50 | public function createContext(SchemaInterface $schema): ValidationContextInterface |
||
| 55 |