You are here

public static function FnStream::decorate in Lockr 7.3

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

Parameters

StreamInterface $stream Stream to decorate:

array $methods Hash of method name to a closure:

Return value

FnStream

File

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

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) {
    $methods[$diff] = [
      $stream,
      $diff,
    ];
  }
  return new self($methods);
}