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
File
-
vendor/
guzzlehttp/ psr7/ src/ FnStream.php, line 80
Class
- FnStream
- Compose stream implementations based on a hash of functions.
Namespace
GuzzleHttp\Psr7Code
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);
}