ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
DroppingStream.php
Go to the documentation of this file.
1 <?php
2 namespace GuzzleHttp\Psr7;
3 
5 
11 {
13 
14  private $maxLength;
15 
21  {
22  $this->stream = $stream;
23  $this->maxLength = $maxLength;
24  }
25 
26  public function write($string)
27  {
28  $diff = $this->maxLength - $this->stream->getSize();
29 
30  // Begin returning 0 when the underlying stream is too large.
31  if ($diff <= 0) {
32  return 0;
33  }
34 
35  // Write the stream or a subset of the stream if needed.
36  if (strlen($string) < $diff) {
37  return $this->stream->write($string);
38  }
39 
40  return $this->stream->write(substr($string, 0, $diff));
41  }
42 }
$stream
PHP stream implementation.
__construct(StreamInterface $stream, $maxLength)
Stream decorator that begins dropping data once the size of the underlying stream becomes too full...
write($string)
Write data to the stream.
Describes a data stream.