Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | public static function fromXML(DOMElement $xml): static |
||
33 | { |
||
34 | Assert::same($xml->localName, static::LOCALNAME, InvalidDOMElementException::class); |
||
35 | Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
||
36 | |||
37 | $children = []; |
||
38 | foreach ($xml->childNodes as $child) { |
||
39 | if (!($child instanceof DOMElement)) { |
||
40 | continue; |
||
41 | } elseif ($child->namespaceURI === static::NS) { |
||
42 | // Only other namespaces are allowed |
||
43 | continue; |
||
44 | } |
||
45 | |||
46 | $children[] = new Chunk($child); |
||
47 | } |
||
48 | |||
49 | return new static( |
||
50 | self::getAttribute($xml, 'name'), |
||
51 | Part::getChildrenOfClass($xml), |
||
52 | $children, |
||
53 | ); |
||
56 |