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

Breadcrumb

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

function Utils::readLine

Read a line from the stream up to the maximum allowed buffer length.

Parameters

StreamInterface $stream Stream to read from:

int|null $maxLength Maximum buffer length:

File

vendor/guzzlehttp/psr7/src/Utils.php, line 234

Class

Utils

Namespace

GuzzleHttp\Psr7

Code

public static function readLine(StreamInterface $stream, ?int $maxLength = null) : string {
    $buffer = '';
    $size = 0;
    while (!$stream->eof()) {
        if ('' === ($byte = $stream->read(1))) {
            return $buffer;
        }
        $buffer .= $byte;
        // Break when a new line is found or the max length - 1 is reached
        if ($byte === "\n" || ++$size === $maxLength - 1) {
            break;
        }
    }
    return $buffer;
}

API Navigation

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