| Conditions | 4 |
| Paths | 4 |
| Total Lines | 36 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public function loadMetadataFromFile(\ReflectionClass $class, $path) |
||
| 17 | { |
||
| 18 | $classMetadata = new ClassMetadata($class->getName()); |
||
|
1 ignored issue
–
show
|
|||
| 19 | |||
| 20 | $dom = new \DOMDocument('1.0'); |
||
| 21 | $dom->load($path); |
||
| 22 | $xpath = new \DOMXpath($dom); |
||
| 23 | $xpath->registerNamespace('psict', self::XML_NAMESPACE); |
||
| 24 | |||
| 25 | foreach ($xpath->query('//psict:class') as $classEl) { |
||
| 26 | $classAttr = $classEl->getAttribute('name'); |
||
| 27 | |||
| 28 | if ($classAttr !== $class->getName()) { |
||
|
1 ignored issue
–
show
|
|||
| 29 | throw new \InvalidArgumentException(sprintf( |
||
| 30 | 'Expected class name to be "%s" but it is mapped as "%s"', |
||
| 31 | $class->getName(), $classAttr |
||
|
1 ignored issue
–
show
|
|||
| 32 | )); |
||
| 33 | } |
||
| 34 | |||
| 35 | foreach ($xpath->query('./psict:field', $classEl) as $fieldEl) { |
||
| 36 | $options = $this->extractOptions($xpath, $fieldEl); |
||
| 37 | $propertyMetadata = new PropertyMetadata( |
||
| 38 | $class->getName(), |
||
|
1 ignored issue
–
show
|
|||
| 39 | $fieldEl->getAttribute('name'), |
||
| 40 | $fieldEl->getAttribute('type'), |
||
| 41 | $fieldEl->getAttribute('role'), |
||
| 42 | $fieldEl->getAttribute('group'), |
||
| 43 | $options |
||
| 44 | ); |
||
| 45 | |||
| 46 | $classMetadata->addPropertyMetadata($propertyMetadata); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | return $classMetadata; |
||
| 51 | } |
||
| 52 | |||
| 77 |