public function insertChildAt($index, self $node)
	{
		if ($node->getParent() != null) {
			$msg = sprintf('Cannot add %s to %s because it already is a child of %s', $node, $this, $node->getParent());
			throw new LogicException($msg);
		}
		if ($index < 0) {
			throw new OutOfRangeException();
		}
		if ($index > count($this->node_children)) {
			throw new OutOfRangeException();
		}
		
		// re-wire new node and insert
		$node->node_parent = $this;
		$node->node_childIndex = $index;
		array_splice($this->node_children, $index, 0, [
			$node
		]);
		
		// update following child indices
		for ($i = $index; $i < count($this->node_children); $i ++) {
			$this->node_children[$i]->childIndex = $i;
		}
		return $this;
	}
public function insertChildAt($index, self $node)
	{
		if ($node->getParent() != null) {
			$msg = sprintf('Cannot add %s to %s because it already is a child of %s', $node, $this, $node->getParent());
			throw new LogicException($msg);
		}
		if ($index < 0) {
			throw new OutOfRangeException();
		}
		if ($index > count($this->node_children)) {
			throw new OutOfRangeException();
		}
		
		// re-wire new node and insert
		$node->node_parent = $this;
		$node->node_childIndex = $index;
		array_splice($this->node_children, $index, 0, [
			$node
		]);
		
		// update following child indices
		for ($i = $index; $i < count($this->node_children); $i ++) {
			$this->node_children[$i]->childIndex = $i;
		}
		return $this;
	}
public function insertChildAt ( $ index , self $ node ) { if ( $ node -> getParent ( ) != null ) { $ msg = sprintf ( 'Cannot add %s to %s because it already is a child of %s' , $ node , $ this , $ node -> getParent ( ) ) ; throw new LogicException ( $ msg ) ; } if ( $ index < 0 ) { throw new OutOfRangeException ( ) ; } if ( $ index > count ( $ this -> node_children ) ) { throw new OutOfRangeException ( ) ; } // re-wire new node and insert $ node -> node_parent = $ this ; $ node -> node_childIndex = $ index ; array_splice ( $ this -> node_children , $ index , 0 , [ $ node ] ) ; // update following child indices for ( $ i = $ index ; $ i < count ( $ this -> node_children ) ; $ i ++ ) { $ this -> node_children [ $ i ] -> childIndex = $ i ; } return $ this ; }
Add the given node at the specified index, moving all children after this index back.
@param int $index
@param self $node
@throws \LogicException
@throws \OutOfRangeException
@return self
Add the given node at the specified index moving all children after this index back .