49 $this->_factory = $factory;
63 $this->_charset = $charset;
64 $this->_factory->charsetChanged($charset);
77 $this->_factory->createMailboxHeader($name, $addresses));
89 $this->_factory->createDateHeader($name, $timestamp));
101 $this->_factory->createTextHeader($name, $value));
115 $this->_factory->createParameterizedHeader($name, $value,
127 $this->
_storeHeader($name, $this->_factory->createIdHeader($name, $ids));
151 public function has($name, $index = 0)
153 $lowerName = strtolower($name);
154 return array_key_exists($lowerName, $this->_headers)
155 && array_key_exists($index, $this->_headers[$lowerName]);
172 $this->
_storeHeader($header->getFieldName(), $header, $index);
186 public function get($name, $index = 0)
188 if ($this->
has($name, $index))
190 $lowerName = strtolower($name);
191 return $this->_headers[$lowerName][$index];
207 foreach ($this->_headers as $collection)
209 $headers = array_merge($headers, $collection);
214 $lowerName = strtolower($name);
215 if (!array_key_exists($lowerName, $this->_headers))
219 return $this->_headers[$lowerName];
230 public function remove($name, $index = 0)
232 $lowerName = strtolower($name);
233 unset($this->_headers[$lowerName][$index]);
243 $lowerName = strtolower($name);
244 unset($this->_headers[$lowerName]);
266 $this->_order = array_flip(array_map(
'strtolower', $sequence));
278 $this->_required = array_flip(array_map(
'strtolower', $names));
302 uksort($headers, array($this,
'_sortHeaders'));
304 foreach ($headers as $collection)
306 foreach ($collection as $header)
308 if ($this->
_isDisplayed($header) || $header->getFieldBody() !=
'')
310 $string .= $header->toString();
334 if (!isset($this->_headers[strtolower($name)]))
336 $this->_headers[strtolower($name)] = array();
340 $this->_headers[strtolower($name)][] = $header;
344 $this->_headers[strtolower($name)][$offset] = $header;
351 return count($this->_order) > 0;
357 $lowerA = strtolower($a);
358 $lowerB = strtolower($b);
359 $aPos = array_key_exists($lowerA, $this->_order)
360 ? $this->_order[$lowerA]
362 $bPos = array_key_exists($lowerB, $this->_order)
363 ? $this->_order[$lowerB]
375 return ($aPos < $bPos) ? -1 : 1;
381 return array_key_exists(strtolower($header->
getFieldName()), $this->_required);
387 foreach ($this->_headers as $headerGroup)
389 foreach ($headerGroup as $header)
391 $header->setCharset($charset);