Conditions | 6 |
Paths | 8 |
Total Lines | 19 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function validate($entity, Constraint $constraint): void |
||
18 | { |
||
19 | $content = $entity->getContent(); |
||
20 | if ($content instanceof ValidComponentInterface) { |
||
21 | $validComponents = $content->getValidComponents(); |
||
22 | if ($validComponents->count()) { |
||
23 | $componentIsValid = false; |
||
24 | $component = $entity->getComponent(); |
||
25 | foreach ($validComponents as $validComponent) { |
||
26 | if (ClassNameValidator::isClassSame($validComponent, $component)) { |
||
27 | $componentIsValid = true; |
||
28 | break; |
||
29 | } |
||
30 | } |
||
31 | if (!$componentIsValid) { |
||
32 | $this->context->buildViolation($constraint->message) |
||
33 | ->atPath('component') |
||
34 | ->setParameter('{{ string }}', implode(', ', $validComponents->toArray())) |
||
35 | ->addViolation(); |
||
36 | } |
||
41 |