public insertBefore ( |
||
$node | the child node of this node's children the new node will be inserted before | |
$newNode | the new node that will be inserted before the first node |
public function insertBefore(Node $node, Node $newNode)
{
$index = $this->indexOf($node);
if ($index === false) {
return $this->prepend($newNode);
}
array_splice($this->children, $index, 0, [$newNode]);
$newNode->parent = $this;
return $this;
}