You are here

public function CachingStream::write in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/src/CachingStream.php \GuzzleHttp\Psr7\CachingStream::write()

Write data to the stream.

Parameters

string $string The string that is to be written.:

Return value

int Returns the number of bytes written to the stream.

Throws

\RuntimeException on failure.

Overrides StreamDecoratorTrait::write

File

vendor/guzzlehttp/psr7/src/CachingStream.php, line 102

Class

CachingStream
Stream decorator that can cache previously read bytes from a sequentially read stream.

Namespace

GuzzleHttp\Psr7

Code

public function write($string) {

  // When appending to the end of the currently read stream, you'll want
  // to skip bytes from being read from the remote stream to emulate
  // other stream wrappers. Basically replacing bytes of data of a fixed
  // length.
  $overflow = strlen($string) + $this
    ->tell() - $this->remoteStream
    ->tell();
  if ($overflow > 0) {
    $this->skipReadBytes += $overflow;
  }
  return $this->stream
    ->write($string);
}