1 | <?php |
||
19 | class PartStreamFilterManager |
||
20 | { |
||
21 | /** |
||
22 | * @var resource compared against the passed $handle in |
||
23 | * attachContentStreamFilter to check that the attached filters are |
||
24 | * applied to the right handle (if it were to change.) |
||
25 | */ |
||
26 | private $cachedHandle; |
||
27 | |||
28 | /** |
||
29 | * @var array map of the active encoding filter active on the current |
||
30 | * PartStreamFilterManager |
||
31 | */ |
||
32 | private $encoding = [ |
||
33 | 'type' => null, |
||
34 | 'filter' => null |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * @var array map of the active charset filter active on the current |
||
39 | * PartStreamFilterManager |
||
40 | */ |
||
41 | private $charset = [ |
||
42 | 'type' => null, |
||
43 | 'filter' => null |
||
44 | ]; |
||
45 | |||
46 | /** |
||
47 | * @var array mapping Content-Transfer-Encoding header values to available |
||
48 | * filters. |
||
49 | */ |
||
50 | private $encodingEncoderMap = [ |
||
51 | 'quoted-printable' => 'mmp-convert.quoted-printable-decode', |
||
52 | 'base64' => 'mmp-convert.base64-decode', |
||
53 | 'x-uuencode' => 'mailmimeparser-uudecode' |
||
54 | ]; |
||
55 | |||
56 | /** |
||
57 | * Attaches a decoding filter to the given handle, for the passed |
||
58 | * $transferEncoding if not already attached to the handle. |
||
59 | * |
||
60 | * Checks the value of $this->encoding['type'] against the passed |
||
61 | * $transferEncoding, and, if identical, does nothing. Otherwise detaches |
||
62 | * any attached transfer encoding decoder filters before attaching a |
||
63 | * relevant one and updating $this->encoding['type']. |
||
64 | * |
||
65 | * @param resource $handle |
||
66 | * @param string $transferEncoding |
||
67 | */ |
||
68 | protected function attachTransferEncodingFilter($handle, $transferEncoding) |
||
85 | |||
86 | /** |
||
87 | * Attaches a charset conversion filter to the given handle, for the passed |
||
88 | * $charset if not already attached to the handle. |
||
89 | * |
||
90 | * Checks the value of $this->charset['type'] against the passed $charset, |
||
91 | * and, if identical, does nothing. Otherwise detaches any attached charset |
||
92 | * conversion filters before attaching a relevant one and updating |
||
93 | * $this->charset['type']. |
||
94 | * |
||
95 | * @param resource $handle |
||
96 | * @param string $charset |
||
97 | */ |
||
98 | protected function attachCharsetFilter($handle, $charset) |
||
116 | |||
117 | /** |
||
118 | * Resets attached transfer-encoding decoder and charset conversion filters |
||
119 | * set for the current manager. |
||
120 | */ |
||
121 | public function reset() |
||
138 | |||
139 | /** |
||
140 | * Checks what transfer-encoding decoder filters and charset conversion |
||
141 | * filters are attached on the handle, detaching them if necessary, before |
||
142 | * attaching relevant filters for the passed $transferEncoding and |
||
143 | * $charset. |
||
144 | * |
||
145 | * @param resource $handle |
||
146 | * @param string $transferEncoding |
||
147 | * @param string $charset |
||
148 | */ |
||
149 | public function attachContentStreamFilters($handle, $transferEncoding, $charset) |
||
158 | } |
||
159 |
If you suppress an error, we recommend checking for the error condition explicitly: