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