123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <?php
-
-
-
-
-
- class Swift_Mime_Headers_IdentificationHeader
- extends Swift_Mime_Headers_AbstractHeader
- {
-
-
-
- private $_ids = array();
-
-
-
- public function __construct($name, Swift_Mime_Grammar $grammar)
- {
- $this->setFieldName($name);
- parent::__construct($grammar);
- }
-
-
-
- public function getFieldType()
- {
- return self::TYPE_ID;
- }
-
-
-
- public function setFieldBodyModel($model)
- {
- $this->setId($model);
- }
-
-
-
- public function getFieldBodyModel()
- {
- return $this->getIds();
- }
-
-
-
- public function setId($id)
- {
- $this->setIds(array($id));
- }
-
-
-
- public function getId()
- {
- if (count($this->_ids) > 0)
- {
- return $this->_ids[0];
- }
- }
-
-
-
- public function setIds(array $ids)
- {
- $actualIds = array();
-
- foreach ($ids as $k => $id)
- {
- $this->_assertValidId($id);
- $actualIds[] = $id;
- }
-
- $this->clearCachedValueIf($this->_ids != $actualIds);
- $this->_ids = $actualIds;
- }
-
-
-
- public function getIds()
- {
- return $this->_ids;
- }
-
-
-
- public function getFieldBody()
- {
- if (!$this->getCachedValue())
- {
- $angleAddrs = array();
-
- foreach ($this->_ids as $id)
- {
- $angleAddrs[] = '<' . $id . '>';
- }
-
- $this->setCachedValue(implode(' ', $angleAddrs));
- }
- return $this->getCachedValue();
- }
-
-
-
- private function _assertValidId($id)
- {
- if (!preg_match(
- '/^' . $this->getGrammar()->getDefinition('id-left') . '@' .
- $this->getGrammar()->getDefinition('id-right') . '$/D',
- $id
- ))
- {
- throw new Swift_RfcComplianceException(
- 'Invalid ID given <' . $id . '>'
- );
- }
- }
- }
|