| Conditions | 5 |
| Paths | 7 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 14 | protected function toSimpleXML( |
||
| 15 | array $input, |
||
| 16 | SimpleXMLElement $parent, |
||
| 17 | bool $alreadySingularized = false |
||
| 18 | ): void { |
||
| 19 | foreach ($input as $key => $value) { |
||
| 20 | |||
| 21 | if (is_numeric($key)) { |
||
| 22 | $name = $alreadySingularized ? |
||
| 23 | 'item' : $this->singularizer->convert($parent->getName()); |
||
| 24 | $singularized = true; |
||
| 25 | } else { |
||
| 26 | $name = str_replace(['<', '>'], '', (string) $key); |
||
| 27 | $singularized = false; |
||
| 28 | } |
||
| 29 | |||
| 30 | if (is_array($value)) { |
||
| 31 | $node = $parent->addChild($name); |
||
| 32 | $this->toSimpleXML($value, $node, $singularized); |
||
| 33 | } else { |
||
| 34 | $parent->addChild( |
||
| 35 | $name, |
||
| 36 | htmlspecialchars((string) $value, ENT_XML1) |
||
| 37 | ); |
||
| 43 |