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\Message; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Implementation of a non-mime message's uuencoded attachment part. |
12
|
|
|
* |
13
|
|
|
* @author Zaahid Bateson |
14
|
|
|
*/ |
15
|
|
|
class UUEncodedPart extends NonMimePart implements IUUEncodedPart |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var int the unix file permission |
19
|
|
|
*/ |
20
|
|
|
protected ?int $mode = null; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string the name of the file in the uuencoding 'header'. |
24
|
|
|
*/ |
25
|
|
|
protected ?string $filename = null; |
26
|
|
|
|
27
|
9 |
|
public function __construct( |
28
|
|
|
?int $mode = null, |
29
|
|
|
?string $filename = null, |
30
|
|
|
?IMimePart $parent = null, |
31
|
|
|
?PartStreamContainer $streamContainer = null |
32
|
|
|
) { |
33
|
9 |
|
parent::__construct( |
34
|
9 |
|
$streamContainer, |
35
|
9 |
|
$parent |
36
|
9 |
|
); |
37
|
9 |
|
$this->mode = $mode; |
38
|
9 |
|
$this->filename = $filename; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Returns the filename included in the uuencoded 'begin' line for this |
43
|
|
|
* part. |
44
|
|
|
*/ |
45
|
4 |
|
public function getFilename() : ?string |
46
|
|
|
{ |
47
|
4 |
|
return $this->filename; |
48
|
|
|
} |
49
|
|
|
|
50
|
1 |
|
public function setFilename(string $filename) : static |
51
|
|
|
{ |
52
|
1 |
|
$this->filename = $filename; |
53
|
1 |
|
$this->notify(); |
54
|
1 |
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Returns false. |
59
|
|
|
* |
60
|
|
|
* Although the part may be plain text, there is no reliable way of |
61
|
|
|
* determining its type since uuencoded 'begin' lines only include a file |
62
|
|
|
* name and no mime type. The file name's extension may be a hint. |
63
|
|
|
* |
64
|
|
|
* @return false |
65
|
|
|
*/ |
66
|
3 |
|
public function isTextPart() : bool |
67
|
|
|
{ |
68
|
3 |
|
return false; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Returns 'application/octet-stream'. |
73
|
|
|
*/ |
74
|
4 |
|
public function getContentType(string $default = 'application/octet-stream') : ?string |
75
|
|
|
{ |
76
|
4 |
|
return 'application/octet-stream'; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Returns null |
81
|
|
|
*/ |
82
|
4 |
|
public function getCharset() : ?string |
83
|
|
|
{ |
84
|
4 |
|
return null; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Returns 'attachment'. |
89
|
|
|
*/ |
90
|
4 |
|
public function getContentDisposition(?string $default = 'attachment') : ?string |
91
|
|
|
{ |
92
|
4 |
|
return 'attachment'; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Returns 'x-uuencode'. |
97
|
|
|
*/ |
98
|
3 |
|
public function getContentTransferEncoding(?string $default = 'x-uuencode') : ?string |
99
|
|
|
{ |
100
|
3 |
|
return 'x-uuencode'; |
101
|
|
|
} |
102
|
|
|
|
103
|
1 |
|
public function getUnixFileMode() : ?int |
104
|
|
|
{ |
105
|
1 |
|
return $this->mode; |
106
|
|
|
} |
107
|
|
|
|
108
|
1 |
|
public function setUnixFileMode(int $mode) : static |
109
|
|
|
{ |
110
|
1 |
|
$this->mode = $mode; |
111
|
1 |
|
$this->notify(); |
112
|
1 |
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function getErrorBagChildren(): array |
116
|
|
|
{ |
117
|
|
|
return \array_merge([]); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|