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;
    }