$xmlRootNodeName =
$context[self::ROOT_NODE_NAME
] ??
$this->defaultContext
[self::ROOT_NODE_NAME
];
$dom =
$this->
createDomDocument($context);
if (null !==
$data && !\
is_scalar($data)) { $root =
$dom->
createElement($xmlRootNodeName);
$dom->
appendChild($root);
$this->
buildXml($root,
$data,
$format,
$context,
$xmlRootNodeName);
} else { $this->
appendNode($dom,
$data,
$format,
$context,
$xmlRootNodeName);
} return $dom->
saveXML($ignorePiNode ?
$dom->documentElement : null,
$context[self::SAVE_OPTIONS
] ??
$this->defaultContext
[self::SAVE_OPTIONS
]);
} public function decode(string
$data, string
$format, array
$context =
[]): mixed
{ if ('' ===
trim($data)) { throw new NotEncodableValueException('Invalid XML data, it cannot be empty.'
);
}