| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function serialize($data): string |
||
| 14 | { |
||
| 15 | if (! is_string($data)) { |
||
| 16 | throw new CantBeSerialized('Only strings can be serialized to xml'); |
||
| 17 | } |
||
| 18 | |||
| 19 | $domDocument = new DOMDocument('1.0'); |
||
| 20 | $domDocument->preserveWhiteSpace = false; |
||
| 21 | $domDocument->formatOutput = true; |
||
| 22 | |||
| 23 | $domDocument->loadXML($data); |
||
| 24 | |||
| 25 | return $domDocument->saveXML(); |
||
| 26 | } |
||
| 27 | |||
| 38 |