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 / ContentTransferEncoding.php
blob0d20f011e27fd560ea69ba9e82ba32ec5a4a2745
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 class ContentTransferEncoding implements HeaderInterface
16 /**
17 * Allowed Content-Transfer-Encoding parameters specified by RFC 1521
18 * (reduced set)
19 * @var array
21 protected static $allowedTransferEncodings = array(
22 '7bit',
23 '8bit',
24 'quoted-printable',
25 'base64',
27 * not implemented:
28 * 'binary',
29 * x-token: 'X-'
34 /**
35 * @var string
37 protected $transferEncoding;
39 /**
40 * @var array
42 protected $parameters = array();
44 public static function fromString($headerLine)
46 $headerLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8');
47 list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
49 // check to ensure proper header type for this factory
50 if (strtolower($name) !== 'content-transfer-encoding') {
51 throw new Exception\InvalidArgumentException('Invalid header line for Content-Transfer-Encoding string');
54 $header = new static();
55 $header->setTransferEncoding($value);
57 return $header;
60 public function getFieldName()
62 return 'Content-Transfer-Encoding';
65 public function getFieldValue($format = HeaderInterface::FORMAT_RAW)
67 return $this->transferEncoding;
70 public function setEncoding($encoding)
72 // Header must be always in US-ASCII
73 return $this;
76 public function getEncoding()
78 return 'ASCII';
81 public function toString()
83 return 'Content-Transfer-Encoding: ' . $this->getFieldValue();
86 /**
87 * Set the content transfer encoding
89 * @param string $transferEncoding
90 * @throws Exception\InvalidArgumentException
91 * @return self
93 public function setTransferEncoding($transferEncoding)
95 if (!in_array($transferEncoding, self::$allowedTransferEncodings)) {
96 throw new Exception\InvalidArgumentException(sprintf(
97 '%s expects one of "'. implode(', ', self::$allowedTransferEncodings) . '"; received "%s"',
98 __METHOD__,
99 (string) $transferEncoding
102 $this->transferEncoding = $transferEncoding;
103 return $this;
107 * Retrieve the content transfer encoding
109 * @return string
111 public function getTransferEncoding()
113 return $this->transferEncoding;