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

Breadcrumb

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

function FnStream::decorate

Adds custom functionality to an underlying stream by intercepting specific method calls.

Parameters

StreamInterface $stream Stream to decorate:

array<string, callable> $methods Hash of method name to a closure:

Return value

FnStream

File

vendor/guzzlehttp/psr7/src/FnStream.php, line 80

Class

FnStream
Compose stream implementations based on a hash of functions.

Namespace

GuzzleHttp\Psr7

Code

public static function decorate(StreamInterface $stream, array $methods) {
    // If any of the required methods were not provided, then simply
    // proxy to the decorated stream.
    foreach (array_diff(self::SLOTS, array_keys($methods)) as $diff) {
        
        /** @var callable $callable */
        $callable = [
            $stream,
            $diff,
        ];
        $methods[$diff] = $callable;
    }
    return new self($methods);
}

API Navigation

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