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\Part; |
9
|
|
|
|
10
|
|
|
use Psr\Log\LoggerInterface; |
11
|
|
|
use ZBateson\MailMimeParser\Header\Part\HeaderPart; |
12
|
|
|
use ZBateson\MbWrapper\MbWrapper; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Holds a string value token that will require additional processing by a |
16
|
|
|
* consumer prior to returning to a client. |
17
|
|
|
* |
18
|
|
|
* A Token is meant to hold a value for further processing -- for instance when |
19
|
|
|
* consuming an address list header (like From or To) -- before it's known what |
20
|
|
|
* type of IHeaderPart it is (could be an email address, could be a name, or |
21
|
|
|
* could be a group.) |
22
|
|
|
* |
23
|
|
|
* @author Zaahid Bateson |
24
|
|
|
*/ |
25
|
|
|
class SubjectToken extends Token |
26
|
|
|
{ |
27
|
|
|
public function __construct( |
28
|
|
|
LoggerInterface $logger, |
29
|
|
|
MbWrapper $charsetConverter, |
30
|
|
|
string $value |
31
|
|
|
) { |
32
|
|
|
parent::__construct($logger, $charsetConverter, $value, true); |
33
|
|
|
$this->value = \preg_replace(['/(\r|\n)+(\s)\s*/', '/(\r|\n)+/'], ['$2', ' '], $value); |
34
|
|
|
$this->isSpace = (\preg_match('/^\s*$/m', $this->value) === 1); |
35
|
|
|
$this->canIgnoreSpacesBefore = $this->canIgnoreSpacesAfter = $this->isSpace; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Returns the part's representative value after any necessary processing |
40
|
|
|
* has been performed. For the raw value, call getRawValue(). |
41
|
|
|
*/ |
42
|
|
|
public function getValue() : string |
43
|
|
|
{ |
44
|
|
|
return $this->convertEncoding($this->value); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|