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

Breadcrumb

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

function DroppingStream::write

Overrides StreamDecoratorTrait::write

File

vendor/guzzlehttp/psr7/src/DroppingStream.php, line 33

Class

DroppingStream
Stream decorator that begins dropping data once the size of the underlying stream becomes too full.

Namespace

GuzzleHttp\Psr7

Code

public function write($string) : int {
    $diff = $this->maxLength - $this->stream
        ->getSize();
    // Begin returning 0 when the underlying stream is too large.
    if ($diff <= 0) {
        return 0;
    }
    // Write the stream or a subset of the stream if needed.
    if (strlen($string) < $diff) {
        return $this->stream
            ->write($string);
    }
    return $this->stream
        ->write(substr($string, 0, $diff));
}

API Navigation

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