MediaWiki  master
MWCallbackStream.php
Go to the documentation of this file.
1 <?php
21 use GuzzleHttp\Psr7\StreamDecoratorTrait;
22 use GuzzleHttp\Psr7\Utils;
23 use Psr\Http\Message\StreamInterface;
24 
36 class MWCallbackStream implements StreamInterface {
37  use StreamDecoratorTrait;
38 
39  private $callback;
40 
41  public function __construct( callable $cb ) {
42  $this->stream = Utils::streamFor();
43  $this->callback = $cb;
44  }
45 
46  public function write( $string ) {
47  return call_user_func( $this->callback, $this, $string );
48  }
49 }
__construct(callable $cb)