File tree Expand file tree Collapse file tree 2 files changed +51
-2
lines changed
Expand file tree Collapse file tree 2 files changed +51
-2
lines changed Original file line number Diff line number Diff line change 22
33namespace React \Stream ;
44
5- use Evenement \EventEmitter ;
6-
75class ThroughStream extends ReadableStream implements WritableStreamInterface
86{
97 private $ pipeSource ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace React \Stream ;
4+
5+ use Evenement \EventEmitter ;
6+
7+ class WritableStream extends EventEmitter implements WritableStreamInterface
8+ {
9+ public $ closed = false ;
10+ private $ pipeSource ;
11+
12+ public function __construct ()
13+ {
14+ $ this ->on ('pipe ' , array ($ this , 'handlePipeEvent ' ));
15+ }
16+
17+ public function handlePipeEvent ($ source )
18+ {
19+ $ this ->pipeSource = $ source ;
20+ }
21+
22+ public function write ($ data )
23+ {
24+ }
25+
26+ public function end ($ data = null )
27+ {
28+ if (null !== $ data ) {
29+ $ this ->write ($ data );
30+ }
31+
32+ $ this ->close ();
33+ }
34+
35+ public function isWritable ()
36+ {
37+ return !$ this ->closed ;
38+ }
39+
40+ public function close ()
41+ {
42+ if ($ this ->closed ) {
43+ return ;
44+ }
45+
46+ $ this ->closed = true ;
47+ $ this ->emit ('end ' , array ($ this ));
48+ $ this ->emit ('close ' , array ($ this ));
49+ $ this ->removeAllListeners ();
50+ }
51+ }
You can’t perform that action at this time.
0 commit comments