FluidXml\FluidContext::appendSibling PHP Method

appendSibling() public method

public appendSibling ( $sibling, $optionals )
    public function appendSibling($sibling, ...$optionals)
    {
        return $this->handler->insertElement($this->nodes, $sibling, $optionals, function ($sibling, $element) {
            if ($sibling->parentNode === null) {
                // If the node doesn't have at least one parent node,
                // the sibling creation fails. In this case we replace
                // the sibling creation with the creation of a child node.
                // Useful when dealing with a DOMDocument with a null
                // documentElement property.
                return $sibling->appendChild($element);
            }
            // If ->nextSibling is null, $element is simply appended as last sibling.
            return $sibling->parentNode->insertBefore($element, $sibling->nextSibling);
        }, $this);
    }