public function DroppingStream::write in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/psr7/src/DroppingStream.php \GuzzleHttp\Psr7\DroppingStream::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/ DroppingStream.php, line 26
Class
- DroppingStream
- Stream decorator that begins dropping data once the size of the underlying stream becomes too full.
Namespace
GuzzleHttp\Psr7Code
public function write($string) {
$diff = $this->maxLength - $this->stream
->getSize();
// Begin returning 0 when the underlying stream is too large.
if ($diff <= 0) {
return 0;
}
// Write the stream or a subset of the stream if needed.
if (strlen($string) < $diff) {
return $this->stream
->write($string);
}
return $this->stream
->write(substr($string, 0, $diff));
}