public function prependChild($nodes)
    {
        if ($this->node->ownerDocument === null) {
            throw new LogicException('Can not prepend child to element without owner document');
        }

        $returnArray = true;

        if (!is_array($nodes)) {
            $nodes = [$nodes];

            $returnArray = false;
        }

        $nodes = array_reverse($nodes);

        $result = [];

        $referenceNode = $this->node->firstChild;

        foreach ($nodes as $node) {
            $result[] = $this->insertBefore($node, $referenceNode);

            $referenceNode = $this->node->firstChild;
        }

        return $returnArray ? $result : $result[0];
    }
public function prependChild($nodes)
    {
        if ($this->node->ownerDocument === null) {
            throw new LogicException('Can not prepend child to element without owner document');
        }

        $returnArray = true;

        if (!is_array($nodes)) {
            $nodes = [$nodes];

            $returnArray = false;
        }

        $nodes = array_reverse($nodes);

        $result = [];

        $referenceNode = $this->node->firstChild;

        foreach ($nodes as $node) {
            $result[] = $this->insertBefore($node, $referenceNode);

            $referenceNode = $this->node->firstChild;
        }

        return $returnArray ? $result : $result[0];
    }
public function prependChild ( $ nodes ) { if ( $ this -> node -> ownerDocument === null ) { throw new LogicException ( 'Can not prepend child to element without owner document' ) ; } $ returnArray = true ; if ( ! is_array ( $ nodes ) ) { $ nodes = [ $ nodes ] ; $ returnArray = false ; } $ nodes = array_reverse ( $ nodes ) ; $ result = [ ] ; $ referenceNode = $ this -> node -> firstChild ; foreach ( $ nodes as $ node ) { $ result [ ] = $ this -> insertBefore ( $ node , $ referenceNode ) ; $ referenceNode = $ this -> node -> firstChild ; } return $ returnArray ? $ result : $ result [ 0 ] ; }
Adds a new child at the start of the children.

@param \DiDom\Element|\DOMNode|array $nodes The prepended child

@return \DiDom\Element|\DiDom\Element[]

@throws \LogicException if current node has no owner document
@throws \InvalidArgumentException if the provided argument is not an instance of \DOMNode or \DiDom\Element
Adds a new child at the start of the children .