Stream.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
  11. use Psr\Http\Message\StreamInterface;
  12. /**
  13. * @author Kévin Dunglas <dunglas@gmail.com>
  14. */
  15. class Stream implements StreamInterface
  16. {
  17. private $stringContent;
  18. private $eof = true;
  19. public function __construct($stringContent = '')
  20. {
  21. $this->stringContent = $stringContent;
  22. }
  23. public function __toString()
  24. {
  25. return $this->stringContent;
  26. }
  27. public function close()
  28. {
  29. }
  30. public function detach()
  31. {
  32. }
  33. public function getSize()
  34. {
  35. }
  36. public function tell()
  37. {
  38. return 0;
  39. }
  40. public function eof()
  41. {
  42. return $this->eof;
  43. }
  44. public function isSeekable()
  45. {
  46. return true;
  47. }
  48. public function seek($offset, $whence = SEEK_SET)
  49. {
  50. }
  51. public function rewind()
  52. {
  53. $this->eof = false;
  54. }
  55. public function isWritable()
  56. {
  57. return false;
  58. }
  59. public function write($string)
  60. {
  61. }
  62. public function isReadable()
  63. {
  64. return true;
  65. }
  66. public function read($length)
  67. {
  68. $this->eof = true;
  69. return $this->stringContent;
  70. }
  71. public function getContents()
  72. {
  73. return $this->stringContent;
  74. }
  75. public function getMetadata($key = null)
  76. {
  77. }
  78. }