public function remove() { if (!$this->valid()) { throw new OutOfBoundsException('The iterator is not valid!'); } $temp = $this->buffer[$this->current]; unset($this->buffer[$this->current]); --$this->current; return $temp; }
public function testApiRemove_ThrowsException_OnInvalidIterator() { $this->setExpectedException(OutOfBoundsException::class); for ($this->iterator->rewind(); $this->iterator->valid(); $this->iterator->next()) { } $this->iterator->remove(); }