Source of file Received.php
Size: 2,255 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Mail/Header/Received.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Mail\Header; use Zend\Mail\Headers; /** * @todo Allow setting date from DateTime, Zend\Date, or string */ class Received implements HeaderInterface, MultipleHeadersInterface { /** * @var string */ protected $value; public static function fromString($headerLine) { list($name, $value) = GenericHeader::splitHeaderLine($headerLine); // check to ensure proper header type for this factory if (strtolower($name) !== 'received') { throw new Exception\InvalidArgumentException('Invalid header line for Received string'); } $header = new static($value); return $header; } public function __construct($value = '') { $this->value = $value; } public function getFieldName() { return 'Received'; } public function getFieldValue($format = HeaderInterface::FORMAT_RAW) { return $this->value; } public function setEncoding($encoding) { // This header must be always in US-ASCII return $this; } public function getEncoding() { return 'ASCII'; } public function toString() { return 'Received: ' . $this->getFieldValue(); } /** * Serialize collection of Received headers to string * * @param array $headers * @throws Exception\RuntimeException * @return string */ public function toStringMultipleHeaders(array $headers) { $strings = array($this->toString()); foreach ($headers as $header) { if (!$header instanceof Received) { throw new Exception\RuntimeException( 'The Received multiple header implementation can only accept an array of Received headers' ); } $strings[] = $header->toString(); } return implode(Headers::EOL, $strings); } } |