ConnectionStub.php 996 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace React\Tests\Socket\Stub;
  3. use Evenement\EventEmitter;
  4. use React\Socket\ConnectionInterface;
  5. use React\Stream\WritableStreamInterface;
  6. use React\Stream\Util;
  7. class ConnectionStub extends EventEmitter implements ConnectionInterface
  8. {
  9. private $data = '';
  10. public function isReadable()
  11. {
  12. return true;
  13. }
  14. public function isWritable()
  15. {
  16. return true;
  17. }
  18. public function pause()
  19. {
  20. }
  21. public function resume()
  22. {
  23. }
  24. public function pipe(WritableStreamInterface $dest, array $options = array())
  25. {
  26. Util::pipe($this, $dest, $options);
  27. return $dest;
  28. }
  29. public function write($data)
  30. {
  31. $this->data .= $data;
  32. return true;
  33. }
  34. public function end($data = null)
  35. {
  36. }
  37. public function close()
  38. {
  39. }
  40. public function getData()
  41. {
  42. return $this->data;
  43. }
  44. public function getRemoteAddress()
  45. {
  46. return '127.0.0.1';
  47. }
  48. }