public function setOffset(int $offset): void
    {
        $current = $this->stream->tell();

        if ($current !== $offset) {
            // If the stream cannot seek to the offset position, then read to it
            if ($this->stream->isSeekable()) {
                $this->stream->seek($offset);
            } elseif ($current > $offset) {
                throw new RuntimeException(\sprintf('Could not seek to stream offset %s', $offset));
            } else {
                $this->stream->read($offset - $current);
            }
        }

        $this->offset = $offset;
    }
public function setOffset(int $offset): void
    {
        $current = $this->stream->tell();

        if ($current !== $offset) {
            // If the stream cannot seek to the offset position, then read to it
            if ($this->stream->isSeekable()) {
                $this->stream->seek($offset);
            } elseif ($current > $offset) {
                throw new RuntimeException(\sprintf('Could not seek to stream offset %s', $offset));
            } else {
                $this->stream->read($offset - $current);
            }
        }

        $this->offset = $offset;
    }
public function setOffset ( int $ offset ) : void { $ current = $ this -> stream -> tell ( ) ; if ( $ current !== $ offset ) { // If the stream cannot seek to the offset position, then read to it if ( $ this -> stream -> isSeekable ( ) ) { $ this -> stream -> seek ( $ offset ) ; } elseif ( $ current > $ offset ) { throw new RuntimeException ( \ sprintf ( 'Could not seek to stream offset %s' , $ offset ) ) ; } else { $ this -> stream -> read ( $ offset - $ current ) ; } } $ this -> offset = $ offset ; }
Set the offset to start limiting from.

@param int $offset Offset to seek to and begin byte limiting from

@throws \Viserio\Component\Contract\Http\Exception\RuntimeException if the stream cannot be seeked

@return void
Set the offset to start limiting from .