NullContentEncoder.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. * Handles the case where the email body is already encoded and you just need specify the correct
  11. * encoding without actually changing the encoding of the body.
  12. *
  13. * @author Jan Flora <jf@penneo.com>
  14. */
  15. class Swift_Mime_ContentEncoder_NullContentEncoder implements Swift_Mime_ContentEncoder
  16. {
  17. /**
  18. * The name of this encoding scheme (probably 7bit or 8bit).
  19. *
  20. * @var string
  21. */
  22. private $name;
  23. /**
  24. * Creates a new NullContentEncoder with $name (probably 7bit or 8bit).
  25. *
  26. * @param string $name
  27. */
  28. public function __construct($name)
  29. {
  30. $this->name = $name;
  31. }
  32. /**
  33. * Encode a given string to produce an encoded string.
  34. *
  35. * @param string $string
  36. * @param int $firstLineOffset ignored
  37. * @param int $maxLineLength ignored
  38. *
  39. * @return string
  40. */
  41. public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
  42. {
  43. return $string;
  44. }
  45. /**
  46. * Encode stream $in to stream $out.
  47. *
  48. * @param int $firstLineOffset ignored
  49. * @param int $maxLineLength ignored
  50. */
  51. public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
  52. {
  53. while (false !== ($bytes = $os->read(8192))) {
  54. $is->write($bytes);
  55. }
  56. }
  57. /**
  58. * Get the name of this encoding scheme.
  59. *
  60. * @return string
  61. */
  62. public function getName()
  63. {
  64. return $this->name;
  65. }
  66. /**
  67. * Not used.
  68. */
  69. public function charsetChanged($charset)
  70. {
  71. }
  72. }