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
Namespace
GuzzleHttp\Psr7Code
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;
}