1 | <?php |
||
16 | class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_AbstractHeader |
||
|
|||
17 | { |
||
18 | /** |
||
19 | * The IDs used in the value of this Header. |
||
20 | * |
||
21 | * This may hold multiple IDs or just a single ID. |
||
22 | * |
||
23 | * @var string[] |
||
24 | */ |
||
25 | private $_ids = array(); |
||
26 | |||
27 | /** |
||
28 | * Creates a new IdentificationHeader with the given $name and $id. |
||
29 | * |
||
30 | * @param string $name |
||
31 | * @param Swift_EmailValidatorBridge $emailValidator |
||
32 | */ |
||
33 | 140 | public function __construct($name, Swift_EmailValidatorBridge $emailValidator) |
|
34 | { |
||
35 | 140 | $this->setFieldName($name); |
|
36 | 140 | $this->_emailValidator = $emailValidator; |
|
37 | 140 | parent::__construct(); |
|
38 | 140 | } |
|
39 | |||
40 | /** |
||
41 | * Get the type of Header that this instance represents. |
||
42 | * |
||
43 | * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX |
||
44 | * @see TYPE_DATE, TYPE_ID, TYPE_PATH |
||
45 | * |
||
46 | * @return int |
||
47 | */ |
||
48 | 1 | public function getFieldType() |
|
52 | |||
53 | /** |
||
54 | * Set the model for the field body. |
||
55 | * |
||
56 | * This method takes a string ID, or an array of IDs. |
||
57 | * |
||
58 | * @param mixed $model |
||
59 | * |
||
60 | * @throws Swift_RfcComplianceException |
||
61 | */ |
||
62 | 123 | public function setFieldBodyModel($model) |
|
66 | |||
67 | /** |
||
68 | * Get the model for the field body. |
||
69 | * |
||
70 | * This method returns an array of IDs |
||
71 | * |
||
72 | * @return string[] |
||
73 | */ |
||
74 | 92 | public function getFieldBodyModel() |
|
78 | |||
79 | /** |
||
80 | * Set the ID used in the value of this header. |
||
81 | * |
||
82 | * @param string|array $id |
||
83 | * |
||
84 | * @throws Swift_RfcComplianceException |
||
85 | */ |
||
86 | 134 | public function setId($id) |
|
87 | { |
||
88 | 134 | if (is_array($id)) { |
|
89 | $this->setIds($id); |
||
90 | } else { |
||
91 | 134 | $this->setIds(array($id)); |
|
92 | } |
||
93 | 133 | } |
|
94 | |||
95 | /** |
||
96 | * Get the ID used in the value of this Header. |
||
97 | * |
||
98 | * If multiple IDs are set only the first is returned. |
||
99 | * |
||
100 | * @return string|null |
||
101 | */ |
||
102 | 6 | public function getId() |
|
103 | { |
||
104 | 6 | if (count($this->_ids) > 0) { |
|
105 | 6 | return $this->_ids[0]; |
|
106 | } else { |
||
107 | return null; |
||
108 | } |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Set a collection of IDs to use in the value of this Header. |
||
113 | * |
||
114 | * @param string[] $ids |
||
115 | * |
||
116 | * @throws Swift_RfcComplianceException |
||
117 | */ |
||
118 | 137 | public function setIds(array $ids) |
|
119 | { |
||
120 | 137 | $actualIds = array(); |
|
121 | |||
122 | 137 | foreach ($ids as $id) { |
|
123 | 137 | $this->_assertValidId($id); |
|
124 | 136 | $actualIds[] = $id; |
|
125 | } |
||
126 | |||
127 | 136 | $this->clearCachedValueIf($this->_ids != $actualIds); |
|
128 | 136 | $this->_ids = $actualIds; |
|
129 | 136 | } |
|
130 | |||
131 | /** |
||
132 | * Get the list of IDs used in this Header. |
||
133 | * |
||
134 | * @return string[] |
||
135 | */ |
||
136 | 94 | public function getIds() |
|
140 | |||
141 | /** |
||
142 | * Get the string value of the body in this Header. |
||
143 | * |
||
144 | * This is not necessarily RFC 2822 compliant since folding white space will |
||
145 | * not be added at this stage (see {@see toString()} for that). |
||
146 | * |
||
147 | * @see toString() |
||
148 | * |
||
149 | * @throws Swift_RfcComplianceException |
||
150 | * |
||
151 | * @return string |
||
152 | */ |
||
153 | 116 | public function getFieldBody() |
|
167 | |||
168 | /** |
||
169 | * Throws an Exception if the id passed does not comply with RFC 2822. |
||
170 | * |
||
171 | * @param string $id |
||
172 | * |
||
173 | * @throws Swift_RfcComplianceException |
||
174 | */ |
||
175 | 137 | private function _assertValidId($id) |
|
183 | } |
||
184 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.