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 / Subject.php
blob0a149340814cef2aee79df548102db8a02cce3ac
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 class Subject implements UnstructuredInterface
14 /**
15 * @var string
17 protected $subject = '';
19 /**
20 * Header encoding
22 * @var string
24 protected $encoding = 'ASCII';
26 public static function fromString($headerLine)
28 $decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8');
29 list($name, $value) = GenericHeader::splitHeaderLine($decodedLine);
31 // check to ensure proper header type for this factory
32 if (strtolower($name) !== 'subject') {
33 throw new Exception\InvalidArgumentException('Invalid header line for Subject string');
36 $header = new static();
37 if ($decodedLine != $headerLine) {
38 $header->setEncoding('UTF-8');
40 $header->setSubject($value);
42 return $header;
45 public function getFieldName()
47 return 'Subject';
50 public function getFieldValue($format = HeaderInterface::FORMAT_RAW)
52 if (HeaderInterface::FORMAT_ENCODED === $format) {
53 return HeaderWrap::wrap($this->subject, $this);
56 return $this->subject;
59 public function setEncoding($encoding)
61 $this->encoding = $encoding;
62 return $this;
65 public function getEncoding()
67 return $this->encoding;
70 public function setSubject($subject)
72 $this->subject = (string) $subject;
73 return $this;
76 public function toString()
78 return 'Subject: ' . $this->getFieldValue(HeaderInterface::FORMAT_ENCODED);