Kraken\Util\Buffer\BufferIterator::insert PHP Method

insert() public method

Insert the given string into the buffer at the current iterator position.
public insert ( string $data )
$data string
    public function insert($data)
    {
        if (!$this->valid()) {
            throw new OutOfBoundsException('The iterator is not valid!');
        }
        $this->buffer[$this->current] = $data . $this->buffer[$this->current];
    }

Usage Example

Ejemplo n.º 1
0
 public function testApiInsert_ThrowsException_OnInvalidIterator()
 {
     $this->setExpectedException(OutOfBoundsException::class);
     for ($this->iterator->rewind(); $this->iterator->valid(); $this->iterator->next()) {
     }
     $this->iterator->insert($this->appendString);
 }