XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
PathHeader.php
Go to the documentation of this file.
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 //@require 'Swift/Mime/Headers/AbstractHeader.php';
12 //@require 'Swift/RfcComplianceException.php';
13 
21 {
22 
28  private $_address;
29 
34  public function __construct($name)
35  {
36  $this->setFieldName($name);
37  $this->initializeGrammar();
38  }
39 
46  public function getFieldType()
47  {
48  return self::TYPE_PATH;
49  }
50 
57  public function setFieldBodyModel($model)
58  {
59  $this->setAddress($model);
60  }
61 
67  public function getFieldBodyModel()
68  {
69  return $this->getAddress();
70  }
71 
77  public function setAddress($address)
78  {
79  if (is_null($address))
80  {
81  $this->_address = null;
82  }
83  elseif ('' == $address
84  || preg_match('/^' . $this->getGrammar('addr-spec') . '$/D', $address))
85  {
86  $this->_address = $address;
87  }
88  else
89  {
91  'Address set in PathHeader does not comply with addr-spec of RFC 2822.'
92  );
93  }
94  $this->setCachedValue(null);
95  }
96 
102  public function getAddress()
103  {
104  return $this->_address;
105  }
106 
114  public function getFieldBody()
115  {
116  if (!$this->getCachedValue())
117  {
118  if (isset($this->_address))
119  {
120  $this->setCachedValue('<' . $this->_address . '>');
121  }
122  }
123  return $this->getCachedValue();
124  }
125 
126 }