@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @throws InvalidMessageDateException |
161 | 161 | */ |
162 | - protected function parse(){ |
|
162 | + protected function parse() { |
|
163 | 163 | if ($this->header === null) { |
164 | 164 | $body = $this->findHeaders(); |
165 | - }else{ |
|
165 | + }else { |
|
166 | 166 | $body = $this->raw; |
167 | 167 | } |
168 | 168 | |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | $this->name = $this->header->get("name"); |
175 | 175 | $this->filename = $this->header->get("filename"); |
176 | 176 | |
177 | - if(!empty($this->header->get("id"))) { |
|
177 | + if (!empty($this->header->get("id"))) { |
|
178 | 178 | $this->id = $this->header->get("id"); |
179 | - } else if(!empty($this->header->get("x_attachment_id"))){ |
|
179 | + }else if (!empty($this->header->get("x_attachment_id"))) { |
|
180 | 180 | $this->id = $this->header->get("x_attachment_id"); |
181 | - } else if(!empty($this->header->get("content_id"))){ |
|
181 | + }else if (!empty($this->header->get("content_id"))) { |
|
182 | 182 | $this->id = strtr($this->header->get("content_id"), [ |
183 | 183 | '<' => '', |
184 | 184 | '>' => '' |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | $content_types = $this->header->get("content_type"); |
189 | - if(!empty($content_types)){ |
|
189 | + if (!empty($content_types)) { |
|
190 | 190 | $this->subtype = $this->parseSubtype($content_types); |
191 | 191 | $content_type = $content_types; |
192 | 192 | if (is_array($content_types)) { |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @return string |
208 | 208 | * @throws InvalidMessageDateException |
209 | 209 | */ |
210 | - private function findHeaders(){ |
|
210 | + private function findHeaders() { |
|
211 | 211 | $body = $this->raw; |
212 | 212 | while (($pos = strpos($body, "\r\n")) > 0) { |
213 | 213 | $body = substr($body, $pos + 2); |
@@ -226,16 +226,16 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - private function parseSubtype($content_type){ |
|
229 | + private function parseSubtype($content_type) { |
|
230 | 230 | if (is_array($content_type)) { |
231 | - foreach ($content_type as $part){ |
|
232 | - if ((strpos($part, "/")) !== false){ |
|
231 | + foreach ($content_type as $part) { |
|
232 | + if ((strpos($part, "/")) !== false) { |
|
233 | 233 | return $this->parseSubtype($part); |
234 | 234 | } |
235 | 235 | } |
236 | 236 | return null; |
237 | 237 | } |
238 | - if (($pos = strpos($content_type, "/")) !== false){ |
|
238 | + if (($pos = strpos($content_type, "/")) !== false) { |
|
239 | 239 | return substr($content_type, $pos + 1); |
240 | 240 | } |
241 | 241 | return null; |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | /** |
245 | 245 | * Try to parse the disposition if any is present |
246 | 246 | */ |
247 | - private function parseDisposition(){ |
|
247 | + private function parseDisposition() { |
|
248 | 248 | $content_disposition = $this->header->get("content_disposition"); |
249 | - if($content_disposition !== null) { |
|
249 | + if ($content_disposition !== null) { |
|
250 | 250 | $this->ifdisposition = true; |
251 | 251 | $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition; |
252 | 252 | } |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | /** |
256 | 256 | * Try to parse the description if any is present |
257 | 257 | */ |
258 | - private function parseDescription(){ |
|
258 | + private function parseDescription() { |
|
259 | 259 | $content_description = $this->header->get("content_description"); |
260 | - if($content_description !== null) { |
|
260 | + if ($content_description !== null) { |
|
261 | 261 | $this->ifdescription = true; |
262 | 262 | $this->description = $content_description; |
263 | 263 | } |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | /** |
267 | 267 | * Try to parse the encoding if any is present |
268 | 268 | */ |
269 | - private function parseEncoding(){ |
|
269 | + private function parseEncoding() { |
|
270 | 270 | $encoding = $this->header->get("content_transfer_encoding"); |
271 | - if($encoding !== null) { |
|
271 | + if ($encoding !== null) { |
|
272 | 272 | switch (strtolower($encoding)) { |
273 | 273 | case "quoted-printable": |
274 | 274 | $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return bool |
300 | 300 | */ |
301 | - public function isAttachment(){ |
|
301 | + public function isAttachment() { |
|
302 | 302 | if ($this->type == IMAP::MESSAGE_TYPE_TEXT && |
303 | 303 | ($this->ifdisposition == 0 || |
304 | 304 | (empty($this->disposition) || !in_array(strtolower($this->disposition), ClientManager::get('options.dispositions'))) |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * @throws MethodNotFoundException |
74 | 74 | */ |
75 | 75 | public function __call($method, $arguments) { |
76 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
76 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
77 | 77 | $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3)); |
78 | 78 | |
79 | - if(in_array($name, array_keys($this->attributes))) { |
|
79 | + if (in_array($name, array_keys($this->attributes))) { |
|
80 | 80 | return $this->attributes[$name]; |
81 | 81 | } |
82 | 82 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @return mixed|null |
103 | 103 | */ |
104 | 104 | public function get($name) { |
105 | - if(isset($this->attributes[$name])) { |
|
105 | + if (isset($this->attributes[$name])) { |
|
106 | 106 | return $this->attributes[$name]; |
107 | 107 | } |
108 | 108 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function find($pattern) { |
119 | 119 | if (preg_match_all($pattern, $this->raw, $matches)) { |
120 | 120 | if (isset($matches[1])) { |
121 | - if(count($matches[1]) > 0) { |
|
121 | + if (count($matches[1]) > 0) { |
|
122 | 122 | return $matches[1][0]; |
123 | 123 | } |
124 | 124 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @throws InvalidMessageDateException |
133 | 133 | */ |
134 | - protected function parse(){ |
|
134 | + protected function parse() { |
|
135 | 135 | $header = $this->rfc822_parse_headers($this->raw); |
136 | 136 | |
137 | 137 | $this->extractAddresses($header); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $this->parseDate($header); |
153 | 153 | foreach ($header as $key => $value) { |
154 | 154 | $key = trim(rtrim(strtolower($key))); |
155 | - if(!isset($this->attributes[$key])){ |
|
155 | + if (!isset($this->attributes[$key])) { |
|
156 | 156 | $this->attributes[$key] = $value; |
157 | 157 | } |
158 | 158 | } |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return object |
170 | 170 | */ |
171 | - public function rfc822_parse_headers($raw_headers){ |
|
171 | + public function rfc822_parse_headers($raw_headers) { |
|
172 | 172 | $headers = []; |
173 | 173 | $imap_headers = []; |
174 | 174 | if (extension_loaded('imap')) { |
175 | 175 | $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw); |
176 | - foreach($raw_imap_headers as $key => $values) { |
|
176 | + foreach ($raw_imap_headers as $key => $values) { |
|
177 | 177 | $key = str_replace("-", "_", $key); |
178 | 178 | $imap_headers[$key] = $values; |
179 | 179 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | $lines = explode("\r\n", $raw_headers); |
183 | 183 | $prev_header = null; |
184 | - foreach($lines as $line) { |
|
184 | + foreach ($lines as $line) { |
|
185 | 185 | if (substr($line, 0, 1) === "\n") { |
186 | 186 | $line = substr($line, 1); |
187 | 187 | } |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | } |
202 | 202 | if (is_array($headers[$prev_header])) { |
203 | 203 | $headers[$prev_header][] = $line; |
204 | - }else{ |
|
204 | + }else { |
|
205 | 205 | $headers[$prev_header] .= $line; |
206 | 206 | } |
207 | 207 | } |
208 | - }else{ |
|
208 | + }else { |
|
209 | 209 | if (($pos = strpos($line, ":")) > 0) { |
210 | 210 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
211 | 211 | $key = str_replace("-", "_", $key); |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - foreach($headers as $key => $values) { |
|
220 | + foreach ($headers as $key => $values) { |
|
221 | 221 | if (isset($imap_headers[$key])) continue; |
222 | 222 | $value = null; |
223 | - switch($key){ |
|
223 | + switch ($key) { |
|
224 | 224 | case 'from': |
225 | 225 | case 'to': |
226 | 226 | case 'cc': |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | break; |
236 | 236 | default: |
237 | 237 | if (is_array($values)) { |
238 | - foreach($values as $k => $v) { |
|
238 | + foreach ($values as $k => $v) { |
|
239 | 239 | if ($v == "") { |
240 | 240 | unset($values[$k]); |
241 | 241 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $value = implode(" ", $values); |
248 | 248 | } elseif ($available_values > 2) { |
249 | 249 | $value = array_values($values); |
250 | - } else { |
|
250 | + }else { |
|
251 | 251 | $value = ""; |
252 | 252 | } |
253 | 253 | } |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | * @return array The decoded elements are returned in an array of objects, where each |
268 | 268 | * object has two properties, charset and text. |
269 | 269 | */ |
270 | - public function mime_header_decode($text){ |
|
270 | + public function mime_header_decode($text) { |
|
271 | 271 | if (extension_loaded('imap')) { |
272 | 272 | return \imap_mime_header_decode($text); |
273 | 273 | } |
274 | 274 | $charset = $this->getEncoding($text); |
275 | - return [(object)[ |
|
275 | + return [(object) [ |
|
276 | 276 | "charset" => $charset, |
277 | 277 | "text" => $this->convertEncoding($text, $charset) |
278 | 278 | ]]; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | try { |
327 | 327 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
328 | 328 | return iconv($from, $to, $str); |
329 | - } else { |
|
329 | + }else { |
|
330 | 330 | if (!$from) { |
331 | 331 | return mb_convert_encoding($str, $to); |
332 | 332 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | if (strstr($from, '-')) { |
337 | 337 | $from = str_replace('-', '', $from); |
338 | 338 | return $this->convertEncoding($str, $from, $to); |
339 | - } else { |
|
339 | + }else { |
|
340 | 340 | return $str; |
341 | 341 | } |
342 | 342 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | } |
358 | 358 | }elseif (property_exists($structure, 'charset')) { |
359 | 359 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
360 | - }elseif (is_string($structure) === true){ |
|
360 | + }elseif (is_string($structure) === true) { |
|
361 | 361 | return mb_detect_encoding($structure); |
362 | 362 | } |
363 | 363 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | $decoder = $this->config['decoder']['message']; |
379 | 379 | |
380 | 380 | if ($value !== null) { |
381 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
381 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
382 | 382 | $value = \imap_utf8($value); |
383 | 383 | if (strpos(strtolower($value), '=?utf-8?') === 0) { |
384 | 384 | $value = mb_decode_mimeheader($value); |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | if ($this->notDecoded($original_value, $value)) { |
387 | 387 | $decoded_value = $this->mime_header_decode($value); |
388 | 388 | if (count($decoded_value) > 0) { |
389 | - if(property_exists($decoded_value[0], "text")) { |
|
389 | + if (property_exists($decoded_value[0], "text")) { |
|
390 | 390 | $value = $decoded_value[0]->text; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | } |
394 | - }elseif($decoder === 'iconv') { |
|
394 | + }elseif ($decoder === 'iconv') { |
|
395 | 395 | $value = iconv_mime_decode($value); |
396 | - }else{ |
|
396 | + }else { |
|
397 | 397 | $value = mb_decode_mimeheader($value); |
398 | 398 | } |
399 | 399 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @return array |
417 | 417 | */ |
418 | 418 | private function decodeArray($values) { |
419 | - foreach($values as $key => $value) { |
|
419 | + foreach ($values as $key => $value) { |
|
420 | 420 | $values[$key] = $this->decode($value); |
421 | 421 | } |
422 | 422 | return $values; |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | * Try to extract the priority from a given raw header string |
427 | 427 | */ |
428 | 428 | private function findPriority() { |
429 | - if(($priority = $this->get("x_priority")) === null) return; |
|
430 | - switch($priority){ |
|
429 | + if (($priority = $this->get("x_priority")) === null) return; |
|
430 | + switch ($priority) { |
|
431 | 431 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
432 | 432 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
433 | 433 | break; |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | */ |
460 | 460 | private function decodeAddresses($values) { |
461 | 461 | $addresses = []; |
462 | - foreach($values as $address) { |
|
462 | + foreach ($values as $address) { |
|
463 | 463 | $address = trim(rtrim($address)); |
464 | 464 | if (strpos($address, ",") == strlen($address) - 1) { |
465 | 465 | $address = substr($address, 0, -1); |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/', |
469 | 469 | $address, |
470 | 470 | $matches |
471 | - )){ |
|
471 | + )) { |
|
472 | 472 | $name = trim(rtrim($matches["name"])); |
473 | 473 | $email = trim(rtrim($matches["email"])); |
474 | 474 | list($mailbox, $host) = array_pad(explode("@", $email), 2, null); |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @param object $header |
488 | 488 | */ |
489 | 489 | private function extractAddresses($header) { |
490 | - foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){ |
|
490 | + foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) { |
|
491 | 491 | if (property_exists($header, $key)) { |
492 | 492 | $this->attributes[$key] = $this->parseAddresses($header->$key); |
493 | 493 | } |
@@ -518,10 +518,10 @@ discard block |
||
518 | 518 | } |
519 | 519 | if (!property_exists($address, 'personal')) { |
520 | 520 | $address->personal = false; |
521 | - } else { |
|
521 | + }else { |
|
522 | 522 | $personalParts = $this->mime_header_decode($address->personal); |
523 | 523 | |
524 | - if(is_array($personalParts)) { |
|
524 | + if (is_array($personalParts)) { |
|
525 | 525 | $address->personal = ''; |
526 | 526 | foreach ($personalParts as $p) { |
527 | 527 | $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p)); |
@@ -541,18 +541,18 @@ discard block |
||
541 | 541 | /** |
542 | 542 | * Search and extract potential header extensions |
543 | 543 | */ |
544 | - private function extractHeaderExtensions(){ |
|
544 | + private function extractHeaderExtensions() { |
|
545 | 545 | foreach ($this->attributes as $key => $value) { |
546 | 546 | // Only parse strings and don't parse any attributes like the user-agent |
547 | 547 | if (is_string($value) === true && in_array($key, ["user_agent"]) === false) { |
548 | - if (($pos = strpos($value, ";")) !== false){ |
|
548 | + if (($pos = strpos($value, ";")) !== false) { |
|
549 | 549 | $original = substr($value, 0, $pos); |
550 | 550 | $this->attributes[$key] = trim(rtrim($original)); |
551 | 551 | |
552 | 552 | // Get all potential extensions |
553 | 553 | $extensions = explode(";", substr($value, $pos + 1)); |
554 | - foreach($extensions as $extension) { |
|
555 | - if (($pos = strpos($extension, "=")) !== false){ |
|
554 | + foreach ($extensions as $extension) { |
|
555 | + if (($pos = strpos($extension, "=")) !== false) { |
|
556 | 556 | $key = substr($extension, 0, $pos); |
557 | 557 | $key = trim(rtrim(strtolower($key))); |
558 | 558 | |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | $parsed_date = null; |
596 | 596 | $date = $header->date; |
597 | 597 | |
598 | - if(preg_match('/\+0580/', $date)) { |
|
598 | + if (preg_match('/\+0580/', $date)) { |
|
599 | 599 | $date = str_replace('+0580', '+0530', $date); |
600 | 600 | } |
601 | 601 | |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | $date = trim(array_pop($array)); |
619 | 619 | break; |
620 | 620 | } |
621 | - try{ |
|
621 | + try { |
|
622 | 622 | $parsed_date = Carbon::parse($date); |
623 | 623 | } catch (\Exception $_e) { |
624 | 624 | throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($prev_header !== null) { |
193 | 193 | $headers[$prev_header][] = $line; |
194 | 194 | } |
195 | - }elseif (substr($line, 0, 1) === " ") { |
|
195 | + } elseif (substr($line, 0, 1) === " ") { |
|
196 | 196 | $line = substr($line, 1); |
197 | 197 | $line = trim(rtrim($line)); |
198 | 198 | if ($prev_header !== null) { |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | } |
202 | 202 | if (is_array($headers[$prev_header])) { |
203 | 203 | $headers[$prev_header][] = $line; |
204 | - }else{ |
|
204 | + } else{ |
|
205 | 205 | $headers[$prev_header] .= $line; |
206 | 206 | } |
207 | 207 | } |
208 | - }else{ |
|
208 | + } else{ |
|
209 | 209 | if (($pos = strpos($line, ":")) > 0) { |
210 | 210 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
211 | 211 | $key = str_replace("-", "_", $key); |
@@ -218,7 +218,9 @@ discard block |
||
218 | 218 | } |
219 | 219 | |
220 | 220 | foreach($headers as $key => $values) { |
221 | - if (isset($imap_headers[$key])) continue; |
|
221 | + if (isset($imap_headers[$key])) { |
|
222 | + continue; |
|
223 | + } |
|
222 | 224 | $value = null; |
223 | 225 | switch($key){ |
224 | 226 | case 'from': |
@@ -355,9 +357,9 @@ discard block |
||
355 | 357 | return EncodingAliases::get($parameter->value, $this->fallback_encoding); |
356 | 358 | } |
357 | 359 | } |
358 | - }elseif (property_exists($structure, 'charset')) { |
|
360 | + } elseif (property_exists($structure, 'charset')) { |
|
359 | 361 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
360 | - }elseif (is_string($structure) === true){ |
|
362 | + } elseif (is_string($structure) === true){ |
|
361 | 363 | return mb_detect_encoding($structure); |
362 | 364 | } |
363 | 365 | |
@@ -391,9 +393,9 @@ discard block |
||
391 | 393 | } |
392 | 394 | } |
393 | 395 | } |
394 | - }elseif($decoder === 'iconv') { |
|
396 | + } elseif($decoder === 'iconv') { |
|
395 | 397 | $value = iconv_mime_decode($value); |
396 | - }else{ |
|
398 | + } else{ |
|
397 | 399 | $value = mb_decode_mimeheader($value); |
398 | 400 | } |
399 | 401 | |
@@ -426,7 +428,9 @@ discard block |
||
426 | 428 | * Try to extract the priority from a given raw header string |
427 | 429 | */ |
428 | 430 | private function findPriority() { |
429 | - if(($priority = $this->get("x_priority")) === null) return; |
|
431 | + if(($priority = $this->get("x_priority")) === null) { |
|
432 | + return; |
|
433 | + } |
|
430 | 434 | switch($priority){ |
431 | 435 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
432 | 436 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws MessageContentFetchingException |
78 | 78 | * @throws InvalidMessageDateException |
79 | 79 | */ |
80 | - protected function parse(){ |
|
80 | + protected function parse() { |
|
81 | 81 | $this->findContentType(); |
82 | 82 | $this->parts = $this->find_parts(); |
83 | 83 | } |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Determine the message content type |
87 | 87 | */ |
88 | - public function findContentType(){ |
|
88 | + public function findContentType() { |
|
89 | 89 | |
90 | 90 | $content_type = $this->header->get("content_type"); |
91 | 91 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
92 | - if(stripos($content_type, 'multipart') === 0) { |
|
92 | + if (stripos($content_type, 'multipart') === 0) { |
|
93 | 93 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
94 | - }else{ |
|
94 | + }else { |
|
95 | 95 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
96 | 96 | } |
97 | 97 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * Determine the message content type |
101 | 101 | */ |
102 | - public function getBoundary(){ |
|
102 | + public function getBoundary() { |
|
103 | 103 | $boundary = $this->header->find("/boundary=\"?([^\"]*)[\";\s]/"); |
104 | 104 | return str_replace('"', '', $boundary); |
105 | 105 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @throws MessageContentFetchingException |
112 | 112 | * @throws InvalidMessageDateException |
113 | 113 | */ |
114 | - public function find_parts(){ |
|
115 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
116 | - if (($boundary = $this->getBoundary()) === null) { |
|
114 | + public function find_parts() { |
|
115 | + if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
116 | + if (($boundary = $this->getBoundary()) === null) { |
|
117 | 117 | throw new MessageContentFetchingException("no content found", 0); |
118 | 118 | } |
119 | 119 | |
@@ -122,21 +122,21 @@ discard block |
||
122 | 122 | ]; |
123 | 123 | |
124 | 124 | if (preg_match("/boundary\=\"?(.*)\"?/", $this->raw, $match) == 1) { |
125 | - if(is_array($match[1])){ |
|
126 | - foreach($match[1] as $matched){ |
|
125 | + if (is_array($match[1])) { |
|
126 | + foreach ($match[1] as $matched) { |
|
127 | 127 | $boundaries[] = str_replace('"', '', $matched); |
128 | 128 | } |
129 | - }else{ |
|
130 | - if(!empty($match[1])) { |
|
129 | + }else { |
|
130 | + if (!empty($match[1])) { |
|
131 | 131 | $boundaries[] = str_replace('"', '', $match[1]); |
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | - $raw_parts = explode( $boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw) ); |
|
136 | + $raw_parts = explode($boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw)); |
|
137 | 137 | $parts = []; |
138 | 138 | $part_number = 0; |
139 | - foreach($raw_parts as $part) { |
|
139 | + foreach ($raw_parts as $part) { |
|
140 | 140 | $part = trim(rtrim($part)); |
141 | 141 | if ($part !== "--") { |
142 | 142 | $parts[] = new Part($part, null, $part_number); |