public function AppendStream::read in Lockr 7.3
Reads from all of the appended streams until the length is met or EOF.
Overrides StreamInterface::read
1 call to AppendStream::read()
- AppendStream::seek in vendor/
guzzlehttp/ psr7/ src/ AppendStream.php - Attempts to seek to the given position. Only supports SEEK_SET.
File
- vendor/
guzzlehttp/ psr7/ src/ AppendStream.php, line 182
Class
- AppendStream
- Reads from multiple streams, one after the other.
Namespace
GuzzleHttp\Psr7Code
public function read($length) {
$buffer = '';
$total = count($this->streams) - 1;
$remaining = $length;
$progressToNext = false;
while ($remaining > 0) {
// Progress to the next stream if needed.
if ($progressToNext || $this->streams[$this->current]
->eof()) {
$progressToNext = false;
if ($this->current === $total) {
break;
}
$this->current++;
}
$result = $this->streams[$this->current]
->read($remaining);
// Using a loose comparison here to match on '', false, and null
if ($result == null) {
$progressToNext = true;
continue;
}
$buffer .= $result;
$remaining = $length - strlen($buffer);
}
$this->pos += strlen($buffer);
return $buffer;
}