Stream.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. public function __construct($stringContent = '')
  19. {
  20. $this->stringContent = $stringContent;
  21. }
  22. public function __toString()
  23. {
  24. return $this->stringContent;
  25. }
  26. public function close()
  27. {
  28. }
  29. public function detach()
  30. {
  31. }
  32. public function getSize()
  33. {
  34. }
  35. public function tell()
  36. {
  37. return 0;
  38. }
  39. public function eof()
  40. {
  41. return true;
  42. }
  43. public function isSeekable()
  44. {
  45. return false;
  46. }
  47. public function seek($offset, $whence = SEEK_SET)
  48. {
  49. }
  50. public function rewind()
  51. {
  52. }
  53. public function isWritable()
  54. {
  55. return false;
  56. }
  57. public function write($string)
  58. {
  59. }
  60. public function isReadable()
  61. {
  62. return true;
  63. }
  64. public function read($length)
  65. {
  66. return $this->stringContent;
  67. }
  68. public function getContents()
  69. {
  70. return $this->stringContent;
  71. }
  72. public function getMetadata($key = null)
  73. {
  74. }
  75. }