| Total Complexity | 3 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | final class XmlSerializer implements SerializerInterface |
||
| 15 | { |
||
| 16 | private Serializer $serializer; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param string $rootTag The name of the root element. |
||
| 20 | * @param string $version The XML version. |
||
| 21 | * @param string $encoding The XML encoding. |
||
| 22 | */ |
||
| 23 | 13 | public function __construct(string $rootTag = 'response', string $version = '1.0', string $encoding = 'UTF-8') |
|
| 24 | { |
||
| 25 | 13 | $this->serializer = new Serializer([new ObjectNormalizer()], [new XmlEncoder([ |
|
| 26 | 13 | XmlEncoder::ROOT_NODE_NAME => $rootTag, |
|
| 27 | 13 | XmlEncoder::VERSION => $version, |
|
| 28 | 13 | XmlEncoder::ENCODING => $encoding, |
|
| 29 | ])]); |
||
| 30 | 13 | } |
|
| 31 | |||
| 32 | 8 | public function serialize($value): string |
|
| 35 | } |
||
| 36 | |||
| 37 | 6 | public function unserialize(string $value) |
|
| 42 |