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

replace() public method

Replace the byte at the current iterator position with the given string.
public replace ( string $data ) : string
$data string
return string
    public function replace($data)
    {
        if (!$this->valid()) {
            throw new OutOfBoundsException('The iterator is not valid!');
        }
        $temp = $this->buffer[$this->current];
        $this->buffer[$this->current] = $data;
        return $temp;
    }

Usage Example

 public function testApiReplace_ThrowsException_OnInvalidIterator()
 {
     $this->setExpectedException(OutOfBoundsException::class);
     for ($this->iterator->rewind(); $this->iterator->valid(); $this->iterator->next()) {
     }
     $this->iterator->replace($this->appendString);
 }