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