| Conditions | 4 |
| Paths | 8 |
| Total Lines | 28 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 2 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public static function loadElement( |
||
| 15 | SchemaReader $reader, |
||
| 16 | Schema $schema, |
||
| 17 | DOMElement $node |
||
| 18 | ): Element { |
||
| 19 | $element = new self($schema, $node->getAttribute('name')); |
||
| 20 | $element->setDoc(SchemaReader::getDocumentation($node)); |
||
| 21 | |||
| 22 | $reader->fillItem($element, $node); |
||
| 23 | |||
| 24 | SchemaReader::maybeSetMax($element, $node); |
||
| 25 | SchemaReader::maybeSetMin($element, $node); |
||
| 26 | |||
| 27 | $xp = new \DOMXPath($node->ownerDocument); |
||
| 28 | $xp->registerNamespace('xs', 'http://www.w3.org/2001/XMLSchema'); |
||
| 29 | |||
| 30 | if ($xp->query('ancestor::xs:choice', $node)->length) { |
||
| 31 | $element->setMin(0); |
||
| 32 | } |
||
| 33 | |||
| 34 | if ($node->hasAttribute('nillable')) { |
||
| 35 | 2 | $element->setNil($node->getAttribute('nillable') == 'true'); |
|
| 36 | } |
||
| 37 | 2 | if ($node->hasAttribute('form')) { |
|
| 38 | $element->setQualified($node->getAttribute('form') == 'qualified'); |
||
| 39 | } |
||
| 40 | |||
| 41 | return $element; |
||
| 42 | } |
||
| 44 |