3 * @see https://github.com/zendframework/zend-mail for the canonical source repository
4 * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
5 * @license https://github.com/zendframework/zend-mail/blob/master/LICENSE.md New BSD License
8 namespace Zend\Mail\Header
;
10 final class HeaderName
13 * No public constructor.
15 private function __construct()
20 * Filter the header name according to RFC 2822
22 * @see http://www.rfc-base.org/txt/rfc-2822.txt (section 2.2)
26 public static function filter($name)
30 for ($i = 0; $i < $tot; $i +
= 1) {
31 $ord = ord($name[$i]);
32 if ($ord > 32 && $ord < 127 && $ord !== 58) {
40 * Determine if the header name contains any invalid characters.
45 public static function isValid($name)
48 for ($i = 0; $i < $tot; $i +
= 1) {
49 $ord = ord($name[$i]);
50 if ($ord < 33 ||
$ord > 126 ||
$ord === 58) {
58 * Assert that the header name is valid.
60 * Raises an exception if invalid.
63 * @throws Exception\RuntimeException
66 public static function assertValid($name)
68 if (! self
::isValid($name)) {
69 throw new Exception\
RuntimeException('Invalid header name detected');