InputByteStream.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * An abstract means of writing data.
  11. *
  12. * Classes implementing this interface may use a subsystem which requires less
  13. * memory than working with large strings of data.
  14. *
  15. * @author Chris Corbyn
  16. */
  17. interface Swift_InputByteStream
  18. {
  19. /**
  20. * Writes $bytes to the end of the stream.
  21. *
  22. * Writing may not happen immediately if the stream chooses to buffer. If
  23. * you want to write these bytes with immediate effect, call {@link commit()}
  24. * after calling write().
  25. *
  26. * This method returns the sequence ID of the write (i.e. 1 for first, 2 for
  27. * second, etc etc).
  28. *
  29. * @param string $bytes
  30. *
  31. * @return int
  32. *
  33. * @throws Swift_IoException
  34. */
  35. public function write($bytes);
  36. /**
  37. * For any bytes that are currently buffered inside the stream, force them
  38. * off the buffer.
  39. *
  40. * @throws Swift_IoException
  41. */
  42. public function commit();
  43. /**
  44. * Attach $is to this stream.
  45. *
  46. * The stream acts as an observer, receiving all data that is written.
  47. * All {@link write()} and {@link flushBuffers()} operations will be mirrored.
  48. *
  49. * @param Swift_InputByteStream $is
  50. */
  51. public function bind(Swift_InputByteStream $is);
  52. /**
  53. * Remove an already bound stream.
  54. *
  55. * If $is is not bound, no errors will be raised.
  56. * If the stream currently has any buffered data it will be written to $is
  57. * before unbinding occurs.
  58. *
  59. * @param Swift_InputByteStream $is
  60. */
  61. public function unbind(Swift_InputByteStream $is);
  62. /**
  63. * Flush the contents of the stream (empty it) and set the internal pointer
  64. * to the beginning.
  65. *
  66. * @throws Swift_IoException
  67. */
  68. public function flushBuffers();
  69. }