pQuery\DomNode::wrap PHP Method

wrap() public method

Wrap node
public wrap ( string | DomNode $node, integer $wrap_index, integer $node_index = null ) : DomNode
$node string | DomNode Wrapping node, string to create new element node
$wrap_index integer Index to insert current node in wrapping node, -1 to append
$node_index integer Index to insert wrapping node, null to keep at same position
return DomNode Wrapping node
    function wrap($node, $wrap_index = -1, $node_index = null)
    {
        if ($node_index === null) {
            $node_index = $this->index();
        }
        if (!is_object($node)) {
            $node = $this->parent->addChild($node, $node_index);
        } elseif ($node->parent !== $this->parent) {
            $node->changeParent($this->parent, $node_index);
        }
        $this->changeParent($node, $wrap_index);
        return $node;
    }
DomNode