Conditions | 7 |
Paths | 16 |
Total Lines | 22 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
14 | public static function parseNode($name, $data): XmlNode { |
||
15 | $node = new XmlNode($name); |
||
16 | |||
17 | if (isset($data[MarshalXml::ATTRIBUTES_KEY])) { |
||
18 | $node->setAttributes($data[MarshalXml::ATTRIBUTES_KEY]); |
||
19 | unset($data[MarshalXml::ATTRIBUTES_KEY]); |
||
20 | } |
||
21 | |||
22 | if (\is_scalar($data)) { |
||
23 | $node->setNodeValue($data); |
||
24 | } elseif (isset($data[MarshalXml::DATA_KEY])) { |
||
25 | $node->setNodeValue($data[MarshalXml::DATA_KEY]); |
||
26 | } elseif (isset($data[MarshalXml::CDATA_KEY])) { |
||
27 | $node->setNodeValue($data[MarshalXml::CDATA_KEY]); |
||
28 | $node->setIsCData(true); |
||
29 | } |
||
30 | |||
31 | if (\is_array($data) && false === $node->hasNodeValue()) { |
||
32 | $node->setChildrenNodes($data); |
||
33 | } |
||
34 | |||
35 | return $node; |
||
36 | } |
||
38 |