Tests the value being passed and decide what sort of element to create
DOMNode $node:
mixed $val:
Boolean
private function selectNodeType($node, $val) {
if (is_array($val)) {
return $this
->buildXml($node, $val);
}
elseif ($val instanceof \SimpleXMLElement) {
$child = $this->dom
->importNode(dom_import_simplexml($val), true);
$node
->appendChild($child);
}
elseif ($val instanceof \Traversable) {
$this
->buildXml($node, $val);
}
elseif (is_object($val)) {
return $this
->buildXml($node, $this->serializer
->normalize($val, $this->format));
}
elseif (is_numeric($val)) {
return $this
->appendText($node, (string) $val);
}
elseif (is_string($val) && $this
->needsCdataWrapping($val)) {
return $this
->appendCData($node, $val);
}
elseif (is_string($val)) {
return $this
->appendText($node, $val);
}
elseif (is_bool($val)) {
return $this
->appendText($node, (int) $val);
}
elseif ($val instanceof \DOMNode) {
$child = $this->dom
->importNode($val, true);
$node
->appendChild($child);
}
return true;
}