Source of file Subject.php
Size: 1,971 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Mail/Header/Subject.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 | <?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; class Subject implements UnstructuredInterface { /** * @var string */ protected $subject = ''; /** * Header encoding * * @var string */ protected $encoding = 'ASCII'; public static function fromString($headerLine) { $decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); list($name, $value) = GenericHeader::splitHeaderLine($decodedLine); // check to ensure proper header type for this factory if (strtolower($name) !== 'subject') { throw new Exception\InvalidArgumentException('Invalid header line for Subject string'); } $header = new static(); if ($decodedLine != $headerLine) { $header->setEncoding('UTF-8'); } $header->setSubject($value); return $header; } public function getFieldName() { return 'Subject'; } public function getFieldValue($format = HeaderInterface::FORMAT_RAW) { if (HeaderInterface::FORMAT_ENCODED === $format) { return HeaderWrap::wrap($this->subject, $this); } return $this->subject; } public function setEncoding($encoding) { $this->encoding = $encoding; return $this; } public function getEncoding() { return $this->encoding; } public function setSubject($subject) { $this->subject = (string) $subject; return $this; } public function toString() { return 'Subject: ' . $this->getFieldValue(HeaderInterface::FORMAT_ENCODED); } } |