1 | <?php |
||
17 | class PartBuilder |
||
18 | { |
||
19 | /** |
||
20 | * @var int The offset read start position for this part (beginning of |
||
21 | * headers) in the message's stream. |
||
22 | */ |
||
23 | private $streamPartStartPos = 0; |
||
24 | |||
25 | /** |
||
26 | * @var int The offset read end position for this part. If the part is a |
||
27 | * multipart mime part, the end position is after all of this parts |
||
28 | * children. |
||
29 | */ |
||
30 | private $streamPartEndPos = 0; |
||
31 | |||
32 | /** |
||
33 | * @var int The offset read start position in the message's stream for the |
||
34 | * beginning of this part's content (body). |
||
35 | */ |
||
36 | private $streamContentStartPos = 0; |
||
37 | |||
38 | /** |
||
39 | * @var int The offset read end position in the message's stream for the |
||
40 | * end of this part's content (body). |
||
41 | */ |
||
42 | private $streamContentEndPos = 0; |
||
43 | |||
44 | /** |
||
45 | * @var \ZBateson\MailMimeParser\Header\HeaderFactory used to parse a |
||
46 | * Content-Type header when needed. |
||
47 | */ |
||
48 | private $headerFactory; |
||
49 | |||
50 | /** |
||
51 | * @var \ZBateson\MailMimeParser\Message\Part\MessagePartFactory the factory |
||
52 | * needed for creating the Message or MessagePart for the parsed part. |
||
53 | */ |
||
54 | private $messagePartFactory; |
||
55 | |||
56 | /** |
||
57 | * @var boolean set to true once the end boundary of the currently-parsed |
||
58 | * part is found. |
||
59 | */ |
||
60 | private $endBoundaryFound = false; |
||
61 | |||
62 | /** |
||
63 | * @var boolean|null|string false if not queried for in the content-type |
||
64 | * header of this part, null if the current part does not have a |
||
65 | * boundary, or the value of the boundary parameter of the content-type |
||
66 | * header if the part contains one. |
||
67 | */ |
||
68 | private $mimeBoundary = false; |
||
69 | |||
70 | /** |
||
71 | * @var string[][] an array of headers on the current part. The key index |
||
72 | * is set to the lower-cased, alphanumeric-only, name of the header |
||
73 | * (after stripping out non-alphanumeric characters, e.g. contenttype) |
||
74 | * and each element containing an array of 2 strings, the first being |
||
75 | * the original name of the header, and the second being the value. |
||
76 | */ |
||
77 | private $headers = []; |
||
78 | |||
79 | /** |
||
80 | * @var PartBuilder[] an array of children found below this part for a mime |
||
81 | |||
82 | */ |
||
83 | private $children = []; |
||
84 | |||
85 | /** |
||
86 | * @var PartBuilder the parent part. |
||
87 | */ |
||
88 | private $parent = null; |
||
89 | |||
90 | /** |
||
91 | * @var string[] key => value pairs of properties passed on to the |
||
92 | * $messagePartFactory when constructing the Message and its children. |
||
93 | */ |
||
94 | private $properties = []; |
||
95 | |||
96 | /** |
||
97 | * @var ZBateson\MailMimeParser\Header\ParameterHeader parsed content-type |
||
98 | * header. |
||
99 | */ |
||
100 | private $contentType = null; |
||
101 | |||
102 | /** |
||
103 | * @var string the PartStream protocol used to create part and content |
||
104 | * filenames for fopen |
||
105 | */ |
||
106 | private $streamWrapperProtocol = null; |
||
107 | |||
108 | /** |
||
109 | * Sets up class dependencies. |
||
110 | * |
||
111 | * @param HeaderFactory $hf |
||
112 | * @param \ZBateson\MailMimeParser\Message\Part\MessagePartFactory $mpf |
||
113 | * @param string $streamWrapperProtocol |
||
114 | */ |
||
115 | public function __construct( |
||
124 | |||
125 | /** |
||
126 | * Adds a header with the given $name and $value to the headers array. |
||
127 | * |
||
128 | * Removes non-alphanumeric characters from $name, and sets it to lower-case |
||
129 | * to use as a key in the private headers array. Sets the original $name |
||
130 | * and $value as elements in the headers' array value for the calculated |
||
131 | * key. |
||
132 | * |
||
133 | * @param string $name |
||
134 | * @param string $value |
||
135 | */ |
||
136 | public function addHeader($name, $value) |
||
141 | |||
142 | /** |
||
143 | * Returns the raw headers added to this PartBuilder as an array consisting |
||
144 | * of: |
||
145 | * |
||
146 | * Keys set to the name of the header, in all lowercase, and with non- |
||
147 | * alphanumeric characters removed (e.g. Content-Type becomes contenttype). |
||
148 | * |
||
149 | * The value is an array of two elements. The first is the original header |
||
150 | * name (e.g. Content-Type) and the second is the raw string value of the |
||
151 | * header, e.g. 'text/html; charset=utf8'. |
||
152 | * |
||
153 | * @return array |
||
154 | */ |
||
155 | public function getRawHeaders() |
||
159 | |||
160 | /** |
||
161 | * Sets the specified property denoted by $name to $value. |
||
162 | * |
||
163 | * @param string $name |
||
164 | * @param mixed $value |
||
165 | */ |
||
166 | public function setProperty($name, $value) |
||
170 | |||
171 | /** |
||
172 | * Returns the value of the property with the given $name. |
||
173 | * |
||
174 | * @param string $name |
||
175 | * @return mixed |
||
176 | */ |
||
177 | public function getProperty($name) |
||
184 | |||
185 | /** |
||
186 | * Registers the passed PartBuilder as a child of the current PartBuilder. |
||
187 | * |
||
188 | * @param \ZBateson\MailMimeParser\Message\PartBuilder $partBuilder |
||
189 | */ |
||
190 | public function addChild(PartBuilder $partBuilder) |
||
195 | |||
196 | /** |
||
197 | * Returns all children PartBuilder objects. |
||
198 | * |
||
199 | * @return \ZBateson\MailMimeParser\Message\PartBuilder[] |
||
200 | */ |
||
201 | public function getChildren() |
||
205 | |||
206 | /** |
||
207 | * Registers the passed PartBuilder as the parent of the current |
||
208 | * PartBuilder. |
||
209 | * |
||
210 | * @param \ZBateson\MailMimeParser\Message\Part\PartBuilder $partBuilder |
||
211 | */ |
||
212 | public function setParent(PartBuilder $partBuilder) |
||
216 | |||
217 | /** |
||
218 | * Returns this PartBuilder's parent. |
||
219 | * |
||
220 | * @return PartBuilder |
||
221 | */ |
||
222 | public function getParent() |
||
226 | |||
227 | /** |
||
228 | * Returns true if either a Content-Type or Mime-Version header are defined |
||
229 | * in this PartBuilder's headers. |
||
230 | * |
||
231 | * @return boolean |
||
232 | */ |
||
233 | public function isMime() |
||
238 | |||
239 | /** |
||
240 | * Returns a ParameterHeader representing the parsed Content-Type header for |
||
241 | * this PartBuilder. |
||
242 | * |
||
243 | * @return \ZBateson\MailMimeParser\Header\ParameterHeader |
||
244 | */ |
||
245 | public function getContentType() |
||
255 | |||
256 | /** |
||
257 | * Returns the parsed boundary parameter of the Content-Type header if set |
||
258 | * for a multipart message part. |
||
259 | * |
||
260 | * @return string |
||
261 | */ |
||
262 | public function getMimeBoundary() |
||
273 | |||
274 | /** |
||
275 | * Returns true if this part's content-type is multipart/* |
||
276 | * |
||
277 | * @return boolean |
||
278 | */ |
||
279 | public function isMultiPart() |
||
291 | |||
292 | /** |
||
293 | * Returns true if the passed $line of read input matches this PartBuilder's |
||
294 | * mime boundary, or any of its parent's mime boundaries for a multipart |
||
295 | * message. |
||
296 | * |
||
297 | * If the passed $line is the ending boundary for the current PartBuilder, |
||
298 | * $this->isEndBoundaryFound will return true after. |
||
299 | * |
||
300 | * @param string $line |
||
301 | * @return boolean |
||
302 | */ |
||
303 | public function setEndBoundary($line) |
||
318 | |||
319 | /** |
||
320 | * Returns true if MessageParser passed an input line to setEndBoundary that |
||
321 | * indicates the end of the part. |
||
322 | * |
||
323 | * @return boolean |
||
324 | */ |
||
325 | public function isEndBoundaryFound() |
||
329 | |||
330 | /** |
||
331 | * Constructs and returns a filename where the part can be read from the |
||
332 | * passed $messageObjectId. |
||
333 | * |
||
334 | * @param string $messageObjectId the message object id |
||
335 | * @return string |
||
336 | */ |
||
337 | public function getStreamPartFilename($messageObjectId) |
||
346 | |||
347 | /** |
||
348 | * Constructs and returns a filename where the part's content can be read |
||
349 | * from the passed $messageObjectId. |
||
350 | * |
||
351 | * @param string $messageObjectId the message object id |
||
352 | * @return string |
||
353 | */ |
||
354 | public function getStreamContentFilename($messageObjectId) |
||
363 | |||
364 | /** |
||
365 | * Sets the start position of the part in the input stream. |
||
366 | * |
||
367 | * @param int $streamPartStartPos |
||
368 | */ |
||
369 | public function setStreamPartStartPos($streamPartStartPos) |
||
373 | |||
374 | /** |
||
375 | * Sets the end position of the part in the input stream. |
||
376 | * |
||
377 | * @param int $streamPartEndPos |
||
378 | */ |
||
379 | public function setStreamPartEndPos($streamPartEndPos) |
||
383 | |||
384 | /** |
||
385 | * Sets the start position of the content in the input stream. |
||
386 | * |
||
387 | * @param int $streamContentStartPos |
||
388 | */ |
||
389 | public function setStreamContentStartPos($streamContentStartPos) |
||
393 | |||
394 | /** |
||
395 | * Sets the end position of the content and part in the input stream. |
||
396 | * |
||
397 | * @param int $streamContentEndPos |
||
398 | */ |
||
399 | public function setStreamPartAndContentEndPos($streamContentEndPos) |
||
404 | |||
405 | /** |
||
406 | * Creates a MessagePart and returns it using the PartBuilder's |
||
407 | * MessagePartFactory passed in during construction. |
||
408 | * |
||
409 | * @param string $messageObjectId |
||
410 | * @return MessagePart |
||
411 | */ |
||
412 | public function createMessagePart($messageObjectId) |
||
419 | } |
||
420 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..