UnstructuredHeader.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. * A Simple MIME Header.
  11. *
  12. * @author Chris Corbyn
  13. */
  14. class Swift_Mime_Headers_UnstructuredHeader extends Swift_Mime_Headers_AbstractHeader
  15. {
  16. /**
  17. * The value of this Header.
  18. *
  19. * @var string
  20. */
  21. private $value;
  22. /**
  23. * Creates a new SimpleHeader with $name.
  24. *
  25. * @param string $name
  26. */
  27. public function __construct($name, Swift_Mime_HeaderEncoder $encoder)
  28. {
  29. $this->setFieldName($name);
  30. $this->setEncoder($encoder);
  31. }
  32. /**
  33. * Get the type of Header that this instance represents.
  34. *
  35. * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
  36. * @see TYPE_DATE, TYPE_ID, TYPE_PATH
  37. *
  38. * @return int
  39. */
  40. public function getFieldType()
  41. {
  42. return self::TYPE_TEXT;
  43. }
  44. /**
  45. * Set the model for the field body.
  46. *
  47. * This method takes a string for the field value.
  48. *
  49. * @param string $model
  50. */
  51. public function setFieldBodyModel($model)
  52. {
  53. $this->setValue($model);
  54. }
  55. /**
  56. * Get the model for the field body.
  57. *
  58. * This method returns a string.
  59. *
  60. * @return string
  61. */
  62. public function getFieldBodyModel()
  63. {
  64. return $this->getValue();
  65. }
  66. /**
  67. * Get the (unencoded) value of this header.
  68. *
  69. * @return string
  70. */
  71. public function getValue()
  72. {
  73. return $this->value;
  74. }
  75. /**
  76. * Set the (unencoded) value of this header.
  77. *
  78. * @param string $value
  79. */
  80. public function setValue($value)
  81. {
  82. $this->clearCachedValueIf($this->value != $value);
  83. $this->value = $value;
  84. }
  85. /**
  86. * Get the value of this header prepared for rendering.
  87. *
  88. * @return string
  89. */
  90. public function getFieldBody()
  91. {
  92. if (!$this->getCachedValue()) {
  93. $this->setCachedValue(
  94. $this->encodeWords($this, $this->value)
  95. );
  96. }
  97. return $this->getCachedValue();
  98. }
  99. }