Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LimitStream.php

function LimitStream::setOffset

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 110

Class

LimitStream
Decorator used to return only a subset of a stream.

Namespace

GuzzleHttp\Psr7

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal