1: <?php
2:
3: namespace React\Stream;
4:
5: use Evenement\EventEmitter;
6:
7: class WritableStream extends EventEmitter implements WritableStreamInterface
8: {
9: protected $closed = false;
10:
11: public function write($data)
12: {
13: return false;
14: }
15:
16: public function end($data = null)
17: {
18: if (null !== $data) {
19: $this->write($data);
20: }
21:
22: $this->close();
23: }
24:
25: public function isWritable()
26: {
27: return !$this->closed;
28: }
29:
30: public function close()
31: {
32: if ($this->closed) {
33: return;
34: }
35:
36: $this->closed = true;
37: $this->emit('close');
38: $this->removeAllListeners();
39: }
40: }
41: