You are here

public function Stream::seek in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/Stream.php \Zend\Diactoros\Stream::seek()
  2. 8 vendor/guzzlehttp/psr7/src/Stream.php \GuzzleHttp\Psr7\Stream::seek()
  3. 8 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Stream::seek()
Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/src/Stream.php \GuzzleHttp\Psr7\Stream::seek()

Seek to a position in the stream.

@link http://www.php.net/manual/en/function.fseek.php

Parameters

int $offset Stream offset:

int $whence Specifies how the cursor position will be calculated: based on the seek offset. Valid values are identical to the built-in PHP $whence values for `fseek()`. SEEK_SET: Set position equal to offset bytes SEEK_CUR: Set position to current location plus offset SEEK_END: Set position to end-of-stream plus offset.

Throws

\RuntimeException on failure.

Overrides StreamInterface::seek

2 calls to Stream::seek()
Stream::rewind in vendor/guzzlehttp/psr7/src/Stream.php
Seek to the beginning of the stream.
Stream::__toString in vendor/guzzlehttp/psr7/src/Stream.php
Reads all data from the stream into a string, from the beginning to end.

File

vendor/guzzlehttp/psr7/src/Stream.php, line 195

Class

Stream
PHP stream implementation.

Namespace

GuzzleHttp\Psr7

Code

public function seek($offset, $whence = SEEK_SET) {
  if (!$this->seekable) {
    throw new \RuntimeException('Stream is not seekable');
  }
  elseif (fseek($this->stream, $offset, $whence) === -1) {
    throw new \RuntimeException('Unable to seek to stream position ' . $offset . ' with whence ' . var_export($whence, true));
  }
}