1: <?php
2:
3: /*
4: * This file is part of SwiftMailer.
5: * (c) 2004-2009 Chris Corbyn
6: *
7: * For the full copyright and license information, please view the LICENSE
8: * file that was distributed with this source code.
9: */
10:
11: /**
12: * A Simple MIME Header.
13: * @package Swift
14: * @subpackage Mime
15: * @author Chris Corbyn
16: */
17: class Swift_Mime_Headers_UnstructuredHeader extends Swift_Mime_Headers_AbstractHeader
18: {
19: /**
20: * The value of this Header.
21: * @var string
22: * @access private
23: */
24: private $_value;
25:
26: /**
27: * Creates a new SimpleHeader with $name.
28: * @param string $name
29: * @param Swift_Mime_HeaderEncoder $encoder
30: * @param Swift_Mime_Grammar $grammar
31: */
32: public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Mime_Grammar $grammar)
33: {
34: $this->setFieldName($name);
35: $this->setEncoder($encoder);
36: parent::__construct($grammar);
37: }
38:
39: /**
40: * Get the type of Header that this instance represents.
41: * @return int
42: * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
43: * @see TYPE_DATE, TYPE_ID, TYPE_PATH
44: */
45: public function getFieldType()
46: {
47: return self::TYPE_TEXT;
48: }
49:
50: /**
51: * Set the model for the field body.
52: * This method takes a string for the field value.
53: * @param string $model
54: */
55: public function setFieldBodyModel($model)
56: {
57: $this->setValue($model);
58: }
59:
60: /**
61: * Get the model for the field body.
62: * This method returns a string.
63: * @return string
64: */
65: public function getFieldBodyModel()
66: {
67: return $this->getValue();
68: }
69:
70: /**
71: * Get the (unencoded) value of this header.
72: * @return string
73: */
74: public function getValue()
75: {
76: return $this->_value;
77: }
78:
79: /**
80: * Set the (unencoded) value of this header.
81: * @param string $value
82: */
83: public function setValue($value)
84: {
85: $this->clearCachedValueIf($this->_value != $value);
86: $this->_value = $value;
87: }
88:
89: /**
90: * Get the value of this header prepared for rendering.
91: * @return string
92: */
93: public function getFieldBody()
94: {
95: if (!$this->getCachedValue()) {
96: $this->setCachedValue(
97: $this->encodeWords($this, $this->_value)
98: );
99: }
100:
101: return $this->getCachedValue();
102: }
103: }
104: