/** * Removes from the list the last element that was returned by next() * @return void * @throws IllegalStateException */ public function remove() { if ($this->canRemove) { $this->list->removeAt($this->index); $this->canRemove = false; } else { throw new IllegalStateException("Cannot remove element unless next has been called"); } }
/** * Replace the node at the specified index in the * receiver with the node argument * @param int $index * @param TreeNodeInterface $node */ public function replaceAt($index, TreeNodeInterface $node) { $node->setParent($this); $this->children->removeAt($index); $this->children->addAt($index, $node); }