src/Web/Communicator.php
protected function convertToDom($values, $element)
    {
        /** @var DOMDocument $document */
        static $document = null;
        $isFirstElement = true;

        if ($element instanceof DOMDocument) {
            $document = $element;
        }
        if (is_array($values)) {
            foreach ($values as $key => $value) {
                if (is_int($key)) {
                    if ($isFirstElement) {
                        $node = $element;
                        $isFirstElement = false;
                    } else {
                        $node = $document->createElement($element->tagName);
                        $element->parentNode->appendChild($node);
                    }
                } else {
                    $node = $document->createElement($key);
                    $element->appendChild($node);
                }
                $this->convertToDom($value, $node);
            }
        } else {
            $element->appendChild($document->createTextNode(is_bool($values) ? ($values ? 'true' : 'false') : $values));
        }

        return $element;
    }
protected function convertToDom($values, $element)
    {
        /** @var DOMDocument $document */
        static $document = null;
        $isFirstElement = true;

        if ($element instanceof DOMDocument) {
            $document = $element;
        }
        if (is_array($values)) {
            foreach ($values as $key => $value) {
                if (is_int($key)) {
                    if ($isFirstElement) {
                        $node = $element;
                        $isFirstElement = false;
                    } else {
                        $node = $document->createElement($element->tagName);
                        $element->parentNode->appendChild($node);
                    }
                } else {
                    $node = $document->createElement($key);
                    $element->appendChild($node);
                }
                $this->convertToDom($value, $node);
            }
        } else {
            $element->appendChild($document->createTextNode(is_bool($values) ? ($values ? 'true' : 'false') : $values));
        }

        return $element;
    }
protected function convertToDom ( $ values , $ element ) { /** @var DOMDocument $document */ static $ document = null ; $ isFirstElement = true ; if ( $ element instanceof DOMDocument ) { $ document = $ element ; } if ( is_array ( $ values ) ) { foreach ( $ values as $ key => $ value ) { if ( is_int ( $ key ) ) { if ( $ isFirstElement ) { $ node = $ element ; $ isFirstElement = false ; } else { $ node = $ document -> createElement ( $ element -> tagName ) ; $ element -> parentNode -> appendChild ( $ node ) ; } } else { $ node = $ document -> createElement ( $ key ) ; $ element -> appendChild ( $ node ) ; } $ this -> convertToDom ( $ value , $ node ) ; } } else { $ element -> appendChild ( $ document -> createTextNode ( is_bool ( $ values ) ? ( $ values ? 'true' : 'false' ) : $ values ) ) ; } return $ element ; }
Recursively converts a value to a DOMDocument|DOMElement.

@param mixed $values
A keyed array, an numerically indexed array, or a scalar type.
@param DOMDocument|DOMElement $element
The element to append the values to.

@return DOMDocument|DOMElement

@throws \DOMException
Recursively converts a value to a DOMDocument|DOMElement .