Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Mail / Header / Received.php
blob5ff26cd8a17eea8324b917b3fa28aae8029fd57b
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Mail\Header;
12 use Zend\Mail\Headers;
14 /**
15 * @todo Allow setting date from DateTime, Zend\Date, or string
17 class Received implements HeaderInterface, MultipleHeadersInterface
19 /**
20 * @var string
22 protected $value;
24 public static function fromString($headerLine)
26 list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
28 // check to ensure proper header type for this factory
29 if (strtolower($name) !== 'received') {
30 throw new Exception\InvalidArgumentException('Invalid header line for Received string');
33 $header = new static($value);
35 return $header;
38 public function __construct($value = '')
40 $this->value = $value;
43 public function getFieldName()
45 return 'Received';
48 public function getFieldValue($format = HeaderInterface::FORMAT_RAW)
50 return $this->value;
53 public function setEncoding($encoding)
55 // This header must be always in US-ASCII
56 return $this;
59 public function getEncoding()
61 return 'ASCII';
64 public function toString()
66 return 'Received: ' . $this->getFieldValue();
69 /**
70 * Serialize collection of Received headers to string
72 * @param array $headers
73 * @throws Exception\RuntimeException
74 * @return string
76 public function toStringMultipleHeaders(array $headers)
78 $strings = array($this->toString());
79 foreach ($headers as $header) {
80 if (!$header instanceof Received) {
81 throw new Exception\RuntimeException(
82 'The Received multiple header implementation can only accept an array of Received headers'
85 $strings[] = $header->toString();
87 return implode(Headers::EOL, $strings);