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