1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the ZBateson\MailMimeParser project. |
4
|
|
|
* |
5
|
|
|
* @license http://opensource.org/licenses/bsd-license.php BSD |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace ZBateson\MailMimeParser\Header; |
9
|
|
|
|
10
|
|
|
use ZBateson\MailMimeParser\Header\Consumer\IdBaseConsumerService; |
11
|
|
|
use ZBateson\MailMimeParser\Header\Part\CommentPart; |
12
|
|
|
use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Represents a Content-ID, Message-ID, In-Reply-To or References header. |
16
|
|
|
* |
17
|
|
|
* For a multi-id header like In-Reply-To or References, all IDs can be |
18
|
|
|
* retrieved by calling {@see IdHeader::getIds()}. Otherwise, to retrieve the |
19
|
|
|
* first (or only) ID call {@see IdHeader::getValue()}. |
20
|
|
|
* |
21
|
|
|
* @author Zaahid Bateson |
22
|
|
|
*/ |
23
|
|
|
class IdHeader extends MimeEncodedHeader |
24
|
|
|
{ |
25
|
90 |
|
public function __construct( |
26
|
|
|
MimeLiteralPartFactory $mimeLiteralPartFactory, |
27
|
|
|
IdBaseConsumerService $consumerService, |
28
|
|
|
string $name, |
29
|
|
|
string $value |
30
|
|
|
) { |
31
|
90 |
|
parent::__construct($mimeLiteralPartFactory, $consumerService, $name, $value); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Returns the ID. Synonymous to calling getValue(). |
36
|
|
|
* |
37
|
|
|
* @return string|null The ID |
38
|
|
|
*/ |
39
|
|
|
public function getId() : ?string |
40
|
|
|
{ |
41
|
|
|
return $this->getValue(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Returns all IDs parsed for a multi-id header like References or |
46
|
|
|
* In-Reply-To. |
47
|
|
|
* |
48
|
|
|
* @return string[] An array of IDs |
49
|
|
|
*/ |
50
|
6 |
|
public function getIds() : array |
51
|
|
|
{ |
52
|
6 |
|
return \array_values(\array_map( |
53
|
6 |
|
function($p) { |
|
|
|
|
54
|
5 |
|
return $p->getValue(); |
55
|
6 |
|
}, |
56
|
6 |
|
\array_filter($this->parts, function($p) { |
|
|
|
|
57
|
5 |
|
return !($p instanceof CommentPart); |
58
|
6 |
|
}) |
59
|
6 |
|
)); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|