Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Header | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php declare(strict_types=1); |
| 2 | /* |
| 3 | * This file is part of Aplus Framework Email Library. |
| 4 | * |
| 5 | * (c) Natan Felles <natanfelles@gmail.com> |
| 6 | * |
| 7 | * For the full copyright and license information, please view the LICENSE |
| 8 | * file that was distributed with this source code. |
| 9 | */ |
| 10 | namespace Framework\Email; |
| 11 | |
| 12 | /** |
| 13 | * Class Header. |
| 14 | * |
| 15 | * @package email |
| 16 | */ |
| 17 | class Header |
| 18 | { |
| 19 | public const AUTO_SUBMITTED = 'Auto-Submitted'; |
| 20 | public const BCC = 'Bcc'; |
| 21 | public const CC = 'Cc'; |
| 22 | public const COMMENTS = 'Comments'; |
| 23 | public const CONTENT_TYPE = 'Content-Type'; |
| 24 | public const DATE = 'Date'; |
| 25 | public const DKIM_SIGNATURE = 'DKIM-Signature'; |
| 26 | public const FROM = 'From'; |
| 27 | public const IN_REPLY_TO = 'In-Reply-To'; |
| 28 | public const KEYWORDS = 'Keywords'; |
| 29 | public const LIST_UNSUBSCRIBE_POST = 'List-Unsubscribe-Post'; |
| 30 | public const MESSAGE_ID = 'Message-ID'; |
| 31 | public const MIME_VERSION = 'MIME-Version'; |
| 32 | public const MT_PRIORITY = 'MT-Priority'; |
| 33 | public const ORIGINAL_FROM = 'Original-From'; |
| 34 | public const ORIGINAL_RECIPIENT = 'Original-Recipient'; |
| 35 | public const ORIGINAL_SUBJECT = 'Original-Subject'; |
| 36 | public const PRIORITY = 'Priority'; |
| 37 | public const RECEIVED = 'Received'; |
| 38 | public const RECEIVED_SPF = 'Received-SPF'; |
| 39 | public const REFERENCES = 'References'; |
| 40 | public const REPLY_TO = 'Reply-To'; |
| 41 | public const RESENT_BCC = 'Resent-Bcc'; |
| 42 | public const RESENT_CC = 'Resent-Cc'; |
| 43 | public const RESENT_DATE = 'Resent-Date'; |
| 44 | public const RESENT_FROM = 'Resent-From'; |
| 45 | public const RESENT_MESSAGE_ID = 'Resent-Message-ID'; |
| 46 | public const RESENT_SENDER = 'Resent-Sender'; |
| 47 | public const RESENT_TO = 'Resent-To'; |
| 48 | public const RETURN_PATH = 'Return-Path'; |
| 49 | public const SENDER = 'Sender'; |
| 50 | public const SUBJECT = 'Subject'; |
| 51 | public const TO = 'To'; |
| 52 | public const X_PRIORITY = 'X-Priority'; |
| 53 | /** |
| 54 | * @var array<string,string> |
| 55 | */ |
| 56 | protected static array $headers = [ |
| 57 | 'auto-submitted' => 'Auto-Submitted', |
| 58 | 'bcc' => 'Bcc', |
| 59 | 'cc' => 'Cc', |
| 60 | 'comments' => 'Comments', |
| 61 | 'content-type' => 'Content-Type', |
| 62 | 'date' => 'Date', |
| 63 | 'dkim-signature' => 'DKIM-Signature', |
| 64 | 'from' => 'From', |
| 65 | 'in-reply-to' => 'In-Reply-To', |
| 66 | 'keywords' => 'Keywords', |
| 67 | 'list-unsubscribe-post' => 'List-Unsubscribe-Post', |
| 68 | 'message-id' => 'Message-ID', |
| 69 | 'mime-version' => 'MIME-Version', |
| 70 | 'mt-priority' => 'MT-Priority', |
| 71 | 'original-from' => 'Original-From', |
| 72 | 'original-recipient' => 'Original-Recipient', |
| 73 | 'original-subject' => 'Original-Subject', |
| 74 | 'priority' => 'Priority', |
| 75 | 'received' => 'Received', |
| 76 | 'received-spf' => 'Received-SPF', |
| 77 | 'references' => 'References', |
| 78 | 'reply-to' => 'Reply-To', |
| 79 | 'resent-bcc' => 'Resent-Bcc', |
| 80 | 'resent-cc' => 'Resent-Cc', |
| 81 | 'resent-date' => 'Resent-Date', |
| 82 | 'resent-from' => 'Resent-From', |
| 83 | 'resent-message-id' => 'Resent-Message-ID', |
| 84 | 'resent-sender' => 'Resent-Sender', |
| 85 | 'resent-to' => 'Resent-To', |
| 86 | 'return-path' => 'Return-Path', |
| 87 | 'sender' => 'Sender', |
| 88 | 'subject' => 'Subject', |
| 89 | 'to' => 'To', |
| 90 | 'x-priority' => 'X-Priority', |
| 91 | ]; |
| 92 | |
| 93 | public static function getName(string $name) : string |
| 94 | { |
| 95 | return static::$headers[\strtolower($name)] ?? $name; |
| 96 | } |
| 97 | |
| 98 | public static function setName(string $name) : void |
| 99 | { |
| 100 | static::$headers[\strtolower($name)] = $name; |
| 101 | } |
| 102 | } |