|
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
|
|
|
namespace ZBateson\MailMimeParser\Header\Part; |
|
8
|
|
|
|
|
9
|
|
|
use ZBateson\MailMimeParser\Util\CharsetConverter; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Represents a name/value pair part of a header. |
|
13
|
|
|
* |
|
14
|
|
|
* @author Zaahid Bateson |
|
15
|
|
|
*/ |
|
16
|
|
|
class ParameterPart extends MimeLiteralPart |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var string the name of the parameter |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $name; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var string the RFC-1766 language tag if set. |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $language; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Constructs a ParameterPart out of a name/value pair. The name and |
|
30
|
|
|
* value are both mime-decoded if necessary. |
|
31
|
|
|
* |
|
32
|
|
|
* If $language is provided, $name and $value are not mime-decoded. Instead, |
|
33
|
|
|
* they're taken as literals as part of a SplitParameterToken. |
|
34
|
|
|
* |
|
35
|
|
|
* @param CharsetConverter $charsetConverter |
|
36
|
|
|
* @param string $name |
|
37
|
|
|
* @param string $value |
|
38
|
|
|
* @param string $language |
|
39
|
|
|
*/ |
|
40
|
5 |
|
public function __construct(CharsetConverter $charsetConverter, $name, $value, $language = null) |
|
41
|
|
|
{ |
|
42
|
5 |
|
if ($language !== null) { |
|
43
|
2 |
|
parent::__construct($charsetConverter, ''); |
|
44
|
2 |
|
$this->name = $name; |
|
45
|
2 |
|
$this->value = $value; |
|
46
|
2 |
|
$this->language = $language; |
|
47
|
2 |
|
} else { |
|
48
|
3 |
|
parent::__construct($charsetConverter, trim($value)); |
|
49
|
3 |
|
$this->name = $this->decodeMime(trim($name)); |
|
50
|
|
|
} |
|
51
|
5 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Returns the name of the parameter. |
|
55
|
|
|
* |
|
56
|
|
|
* @return string |
|
57
|
|
|
*/ |
|
58
|
4 |
|
public function getName() |
|
59
|
|
|
{ |
|
60
|
4 |
|
return $this->name; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Returns the RFC-1766 (or subset) language tag, if the parameter is a |
|
65
|
|
|
* split RFC-2231 part with a language tag set. |
|
66
|
|
|
* |
|
67
|
|
|
* @return string |
|
68
|
|
|
*/ |
|
69
|
1 |
|
public function getLanguage() |
|
70
|
|
|
{ |
|
71
|
1 |
|
return $this->language; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|