Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AppendStream.php

function AppendStream::read

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 188

Class

AppendStream
Reads from multiple streams, one after the other.

Namespace

GuzzleHttp\Psr7

Code

public function read($length) : string {
    $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);
        if ($result === '') {
            $progressToNext = true;
            continue;
        }
        $buffer .= $result;
        $remaining = $length - strlen($buffer);
    }
    $this->pos += strlen($buffer);
    return $buffer;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal