OpenDKIMHeader.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 OpenDKIM Specific Header using only raw header datas without encoding
  11. *
  12. * @author De Cock Xavier <xdecock@gmail.com>
  13. */
  14. class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header
  15. {
  16. /**
  17. * The value of this Header.
  18. *
  19. * @var string
  20. */
  21. private $_value;
  22. /**
  23. * The name of this Header
  24. * @var string
  25. */
  26. private $_fieldName;
  27. /**
  28. * Creates a new SimpleHeader with $name.
  29. *
  30. * @param string $name
  31. * @param Swift_Mime_HeaderEncoder $encoder
  32. * @param Swift_Mime_Grammar $grammar
  33. */
  34. public function __construct($name)
  35. {
  36. $this->_fieldName = $name;
  37. }
  38. /**
  39. * Get the type of Header that this instance represents.
  40. *
  41. * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
  42. * @see TYPE_DATE, TYPE_ID, TYPE_PATH
  43. *
  44. * @return int
  45. */
  46. public function getFieldType()
  47. {
  48. return self::TYPE_TEXT;
  49. }
  50. /**
  51. * Set the model for the field body.
  52. *
  53. * This method takes a string for the field value.
  54. *
  55. * @param string $model
  56. */
  57. public function setFieldBodyModel($model)
  58. {
  59. $this->setValue($model);
  60. }
  61. /**
  62. * Get the model for the field body.
  63. *
  64. * This method returns a string.
  65. *
  66. * @return string
  67. */
  68. public function getFieldBodyModel()
  69. {
  70. return $this->getValue();
  71. }
  72. /**
  73. * Get the (unencoded) value of this header.
  74. *
  75. * @return string
  76. */
  77. public function getValue()
  78. {
  79. return $this->_value;
  80. }
  81. /**
  82. * Set the (unencoded) value of this header.
  83. *
  84. * @param string $value
  85. */
  86. public function setValue($value)
  87. {
  88. $this->_value = $value;
  89. }
  90. /**
  91. * Get the value of this header prepared for rendering.
  92. *
  93. * @return string
  94. */
  95. public function getFieldBody()
  96. {
  97. return $this->_value;
  98. }
  99. /**
  100. * Get this Header rendered as a RFC 2822 compliant string.
  101. *
  102. * @return string
  103. */
  104. public function toString()
  105. {
  106. return $this->_fieldName.': '.$this->_value;
  107. }
  108. /**
  109. * Set the Header FieldName
  110. * @see Swift_Mime_Header::getFieldName()
  111. */
  112. public function getFieldName()
  113. {
  114. return $this->_fieldName;
  115. }
  116. /**
  117. * Ignored
  118. */
  119. public function setCharset($charset)
  120. {
  121. }
  122. }