TrackManiaControl/libs/React/Stream/ThroughStream.php

34 lines
660 B
PHP
Raw Permalink Normal View History

<?php
namespace React\Stream;
class ThroughStream extends CompositeStream
{
public function __construct()
{
$readable = new ReadableStream();
$writable = new WritableStream();
parent::__construct($readable, $writable);
}
public function filter($data)
{
return $data;
}
public function write($data)
{
$this->readable->emit('data', array($this->filter($data), $this));
}
public function end($data = null)
{
if (null !== $data) {
$this->readable->emit('data', array($this->filter($data), $this));
}
$this->writable->end($data);
}
}