| Conditions | 5 |
| Paths | 5 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 6 | public function read(FormInterface $form): array |
|
| 29 | { |
||
| 30 | 6 | $config = $form->getRoot()->getConfig(); |
|
| 31 | 6 | if (null === $config->getDataClass()) { |
|
| 32 | 1 | return []; |
|
| 33 | } |
||
| 34 | |||
| 35 | try { |
||
| 36 | 5 | $metadata = $this->validator->getMetadataFor($config->getDataClass()); |
|
| 37 | 1 | } catch (NoSuchMetadataException $exception) { |
|
| 38 | 1 | return []; |
|
| 39 | } |
||
| 40 | |||
| 41 | 4 | if (!$metadata instanceof ClassMetadata) { |
|
| 42 | 1 | return []; |
|
| 43 | } |
||
| 44 | |||
| 45 | 3 | $constraints = []; |
|
| 46 | 3 | foreach ($metadata->getPropertyMetadata($form->getName()) as $propertyMetadatum) { |
|
| 47 | 2 | $constraints = array_merge($constraints, $propertyMetadatum->findConstraints($metadata->getDefaultGroup())); |
|
| 48 | } |
||
| 49 | |||
| 50 | 3 | return $constraints; |
|
| 51 | } |
||
| 66 |