You are here

public function LimitStream::setOffset in Auth0 Single Sign On 8.2

Set the offset to start limiting from

Parameters

int $offset Offset to seek to and begin byte limiting from:

Throws

\RuntimeException if the stream cannot be seeked.

1 call to LimitStream::setOffset()
LimitStream::__construct in vendor/guzzlehttp/psr7/src/LimitStream.php

File

vendor/guzzlehttp/psr7/src/LimitStream.php, line 108

Class

LimitStream
Decorator used to return only a subset of a stream

Namespace

GuzzleHttp\Psr7

Code

public function setOffset($offset) {
  $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("Could not seek to stream offset {$offset}");
    }
    else {
      $this->stream
        ->read($offset - $current);
    }
  }
  $this->offset = $offset;
}