@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | public function __construct($msgn, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false) { |
196 | 196 | |
197 | 197 | $default_mask = $client->getDefaultMessageMask(); |
198 | - if($default_mask != null) { |
|
198 | + if ($default_mask != null) { |
|
199 | 199 | $this->mask = $default_mask; |
200 | 200 | } |
201 | 201 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | * @throws MethodNotFoundException |
241 | 241 | */ |
242 | 242 | public function __call($method, $arguments) { |
243 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
243 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
244 | 244 | $name = Str::snake(substr($method, 3)); |
245 | 245 | return $this->get($name); |
246 | 246 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
247 | 247 | $name = Str::snake(substr($method, 3)); |
248 | 248 | |
249 | - if(in_array($name, array_keys($this->attributes))) { |
|
249 | + if (in_array($name, array_keys($this->attributes))) { |
|
250 | 250 | $this->attributes[$name] = array_pop($arguments); |
251 | 251 | |
252 | 252 | return $this->attributes[$name]; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @return mixed|null |
288 | 288 | */ |
289 | 289 | public function get($name) { |
290 | - if(isset($this->attributes[$name])) { |
|
290 | + if (isset($this->attributes[$name])) { |
|
291 | 291 | return $this->attributes[$name]; |
292 | 292 | } |
293 | 293 | |
@@ -369,8 +369,8 @@ discard block |
||
369 | 369 | $flags = $this->client->getConnection()->flags([$this->msgn]); |
370 | 370 | |
371 | 371 | if (isset($flags[$this->msgn])) { |
372 | - foreach($flags[$this->msgn] as $flag) { |
|
373 | - if (strpos($flag, "\\") === 0){ |
|
372 | + foreach ($flags[$this->msgn] as $flag) { |
|
373 | + if (strpos($flag, "\\") === 0) { |
|
374 | 374 | $flag = substr($flag, 1); |
375 | 375 | } |
376 | 376 | $flag_key = strtolower($flag); |
@@ -434,9 +434,9 @@ discard block |
||
434 | 434 | */ |
435 | 435 | private function fetchPart(Part $part) { |
436 | 436 | |
437 | - if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])) ) ) { |
|
437 | + if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])))) { |
|
438 | 438 | |
439 | - if ( in_array(($subtype = strtolower($part->subtype)), ["plain", "csv", "html"]) && $part->filename == null && $part->name == null) { |
|
439 | + if (in_array(($subtype = strtolower($part->subtype)), ["plain", "csv", "html"]) && $part->filename == null && $part->name == null) { |
|
440 | 440 | $encoding = $this->getEncoding($part); |
441 | 441 | |
442 | 442 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -457,10 +457,10 @@ discard block |
||
457 | 457 | } |
458 | 458 | |
459 | 459 | $this->bodies[$subtype == "plain" ? "text" : $subtype] = $content; |
460 | - } else { |
|
460 | + }else { |
|
461 | 461 | $this->fetchAttachment($part); |
462 | 462 | } |
463 | - } else { |
|
463 | + }else { |
|
464 | 464 | $this->fetchAttachment($part); |
465 | 465 | } |
466 | 466 | } |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | if ($oAttachment->getName() !== null) { |
477 | 477 | if ($oAttachment->getId() !== null) { |
478 | 478 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
479 | - } else { |
|
479 | + }else { |
|
480 | 480 | $this->attachments->push($oAttachment); |
481 | 481 | } |
482 | 482 | } |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | |
594 | 594 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
595 | 595 | return @iconv($from, $to.'//IGNORE', $str); |
596 | - } else { |
|
596 | + }else { |
|
597 | 597 | if (!$from) { |
598 | 598 | return mb_convert_encoding($str, $to); |
599 | 599 | } |
@@ -614,9 +614,9 @@ discard block |
||
614 | 614 | return EncodingAliases::get($parameter->value); |
615 | 615 | } |
616 | 616 | } |
617 | - }elseif (property_exists($structure, 'charset')){ |
|
617 | + }elseif (property_exists($structure, 'charset')) { |
|
618 | 618 | return EncodingAliases::get($structure->charset); |
619 | - }elseif (is_string($structure) === true){ |
|
619 | + }elseif (is_string($structure) === true) { |
|
620 | 620 | return mb_detect_encoding($structure); |
621 | 621 | } |
622 | 622 | |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * @throws Exceptions\ConnectionFailedException |
631 | 631 | * @throws Exceptions\FolderFetchingException |
632 | 632 | */ |
633 | - public function getFolder(){ |
|
633 | + public function getFolder() { |
|
634 | 634 | return $this->client->getFolder($this->folder_path); |
635 | 635 | } |
636 | 636 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | |
661 | 661 | $this->client->openFolder($this->folder_path); |
662 | 662 | if ($this->client->getConnection()->copyMessage($folder->path, $this->msgn) == true) { |
663 | - if($expunge) $this->client->expunge(); |
|
663 | + if ($expunge) $this->client->expunge(); |
|
664 | 664 | |
665 | 665 | $this->client->openFolder($folder->path); |
666 | 666 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | |
703 | 703 | $this->client->openFolder($this->folder_path); |
704 | 704 | if ($this->client->getConnection()->moveMessage($folder->path, $this->msgn) == true) { |
705 | - if($expunge) $this->client->expunge(); |
|
705 | + if ($expunge) $this->client->expunge(); |
|
706 | 706 | |
707 | 707 | $this->client->openFolder($folder->path); |
708 | 708 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | */ |
730 | 730 | public function delete($expunge = true) { |
731 | 731 | $status = $this->setFlag("Deleted"); |
732 | - if($expunge) $this->client->expunge(); |
|
732 | + if ($expunge) $this->client->expunge(); |
|
733 | 733 | |
734 | 734 | $event = $this->getEvent("message", "deleted"); |
735 | 735 | $event::dispatch($this); |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | */ |
749 | 749 | public function restore($expunge = true) { |
750 | 750 | $status = $this->unsetFlag("Deleted"); |
751 | - if($expunge) $this->client->expunge(); |
|
751 | + if ($expunge) $this->client->expunge(); |
|
752 | 752 | |
753 | 753 | $event = $this->getEvent("message", "restored"); |
754 | 754 | $event::dispatch($this); |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | * |
902 | 902 | * @return object|null |
903 | 903 | */ |
904 | - public function getStructure(){ |
|
904 | + public function getStructure() { |
|
905 | 905 | return $this->structure; |
906 | 906 | } |
907 | 907 | |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | * |
928 | 928 | * @return array |
929 | 929 | */ |
930 | - public function getAttributes(){ |
|
930 | + public function getAttributes() { |
|
931 | 931 | return array_merge($this->attributes, $this->header->getAttributes()); |
932 | 932 | } |
933 | 933 | |
@@ -937,8 +937,8 @@ discard block |
||
937 | 937 | * |
938 | 938 | * @return $this |
939 | 939 | */ |
940 | - public function setMask($mask){ |
|
941 | - if(class_exists($mask)){ |
|
940 | + public function setMask($mask) { |
|
941 | + if (class_exists($mask)) { |
|
942 | 942 | $this->mask = $mask; |
943 | 943 | } |
944 | 944 | |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | * |
951 | 951 | * @return string |
952 | 952 | */ |
953 | - public function getMask(){ |
|
953 | + public function getMask() { |
|
954 | 954 | return $this->mask; |
955 | 955 | } |
956 | 956 | |
@@ -961,9 +961,9 @@ discard block |
||
961 | 961 | * @return mixed |
962 | 962 | * @throws MaskNotFoundException |
963 | 963 | */ |
964 | - public function mask($mask = null){ |
|
964 | + public function mask($mask = null) { |
|
965 | 965 | $mask = $mask !== null ? $mask : $this->mask; |
966 | - if(class_exists($mask)){ |
|
966 | + if (class_exists($mask)) { |
|
967 | 967 | return new $mask($this); |
968 | 968 | } |
969 | 969 |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | if(strtolower(substr($method, 0, 3)) === 'get') { |
244 | 244 | $name = Str::snake(substr($method, 3)); |
245 | 245 | return $this->get($name); |
246 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
246 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
247 | 247 | $name = Str::snake(substr($method, 3)); |
248 | 248 | |
249 | 249 | if(in_array($name, array_keys($this->attributes))) { |
@@ -614,9 +614,9 @@ discard block |
||
614 | 614 | return EncodingAliases::get($parameter->value); |
615 | 615 | } |
616 | 616 | } |
617 | - }elseif (property_exists($structure, 'charset')){ |
|
617 | + } elseif (property_exists($structure, 'charset')){ |
|
618 | 618 | return EncodingAliases::get($structure->charset); |
619 | - }elseif (is_string($structure) === true){ |
|
619 | + } elseif (is_string($structure) === true){ |
|
620 | 620 | return mb_detect_encoding($structure); |
621 | 621 | } |
622 | 622 | |
@@ -660,7 +660,9 @@ discard block |
||
660 | 660 | |
661 | 661 | $this->client->openFolder($this->folder_path); |
662 | 662 | if ($this->client->getConnection()->copyMessage($folder->path, $this->msgn) == true) { |
663 | - if($expunge) $this->client->expunge(); |
|
663 | + if($expunge) { |
|
664 | + $this->client->expunge(); |
|
665 | + } |
|
664 | 666 | |
665 | 667 | $this->client->openFolder($folder->path); |
666 | 668 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -702,7 +704,9 @@ discard block |
||
702 | 704 | |
703 | 705 | $this->client->openFolder($this->folder_path); |
704 | 706 | if ($this->client->getConnection()->moveMessage($folder->path, $this->msgn) == true) { |
705 | - if($expunge) $this->client->expunge(); |
|
707 | + if($expunge) { |
|
708 | + $this->client->expunge(); |
|
709 | + } |
|
706 | 710 | |
707 | 711 | $this->client->openFolder($folder->path); |
708 | 712 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -729,7 +733,9 @@ discard block |
||
729 | 733 | */ |
730 | 734 | public function delete($expunge = true) { |
731 | 735 | $status = $this->setFlag("Deleted"); |
732 | - if($expunge) $this->client->expunge(); |
|
736 | + if($expunge) { |
|
737 | + $this->client->expunge(); |
|
738 | + } |
|
733 | 739 | |
734 | 740 | $event = $this->getEvent("message", "deleted"); |
735 | 741 | $event::dispatch($this); |
@@ -748,7 +754,9 @@ discard block |
||
748 | 754 | */ |
749 | 755 | public function restore($expunge = true) { |
750 | 756 | $status = $this->unsetFlag("Deleted"); |
751 | - if($expunge) $this->client->expunge(); |
|
757 | + if($expunge) { |
|
758 | + $this->client->expunge(); |
|
759 | + } |
|
752 | 760 | |
753 | 761 | $event = $this->getEvent("message", "restored"); |
754 | 762 | $event::dispatch($this); |
@@ -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; |
@@ -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,7 +168,7 @@ 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')) { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $lines = explode("\r\n", $raw_headers); |
179 | 179 | $prev_header = null; |
180 | - foreach($lines as $line) { |
|
180 | + foreach ($lines as $line) { |
|
181 | 181 | if (substr($line, 0, 1) === "\n") { |
182 | 182 | $line = substr($line, 1); |
183 | 183 | } |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | } |
198 | 198 | if (is_array($headers[$prev_header])) { |
199 | 199 | $headers[$prev_header][] = $line; |
200 | - }else{ |
|
200 | + }else { |
|
201 | 201 | $headers[$prev_header] .= $line; |
202 | 202 | } |
203 | 203 | } |
204 | - }else{ |
|
204 | + }else { |
|
205 | 205 | if (($pos = strpos($line, ":")) > 0) { |
206 | 206 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
207 | 207 | $value = trim(rtrim(strtolower(substr($line, $pos + 1)))); |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | - foreach($headers as $key => $values) { |
|
214 | + foreach ($headers as $key => $values) { |
|
215 | 215 | if (isset($imap_headers[$key])) continue; |
216 | 216 | $value = null; |
217 | - switch($key){ |
|
217 | + switch ($key) { |
|
218 | 218 | case 'from': |
219 | 219 | case 'to': |
220 | 220 | case 'cc': |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | break; |
230 | 230 | default: |
231 | 231 | if (is_array($values)) { |
232 | - foreach($values as $k => $v) { |
|
232 | + foreach ($values as $k => $v) { |
|
233 | 233 | if ($v == "") { |
234 | 234 | unset($values[$k]); |
235 | 235 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $value = implode(" ", $values); |
242 | 242 | } elseif ($available_values > 2) { |
243 | 243 | $value = array_values($values); |
244 | - } else { |
|
244 | + }else { |
|
245 | 245 | $value = ""; |
246 | 246 | } |
247 | 247 | } |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | * @return array The decoded elements are returned in an array of objects, where each |
262 | 262 | * object has two properties, charset and text. |
263 | 263 | */ |
264 | - public function mime_header_decode($text){ |
|
264 | + public function mime_header_decode($text) { |
|
265 | 265 | if (extension_loaded('imap')) { |
266 | 266 | return \imap_mime_header_decode($text); |
267 | 267 | } |
268 | 268 | $charset = $this->getEncoding($text); |
269 | - return [(object)[ |
|
269 | + return [(object) [ |
|
270 | 270 | "charset" => $charset, |
271 | 271 | "text" => $this->convertEncoding($text, $charset) |
272 | 272 | ]]; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
322 | 322 | return iconv($from, $to, $str); |
323 | - } else { |
|
323 | + }else { |
|
324 | 324 | if (!$from) { |
325 | 325 | return mb_convert_encoding($str, $to); |
326 | 326 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | if (strstr($from, '-')) { |
331 | 331 | $from = str_replace('-', '', $from); |
332 | 332 | return $this->convertEncoding($str, $from, $to); |
333 | - } else { |
|
333 | + }else { |
|
334 | 334 | return $str; |
335 | 335 | } |
336 | 336 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | }elseif (property_exists($structure, 'charset')) { |
353 | 353 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
354 | - }elseif (is_string($structure) === true){ |
|
354 | + }elseif (is_string($structure) === true) { |
|
355 | 355 | return mb_detect_encoding($structure); |
356 | 356 | } |
357 | 357 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | $decoder = $this->config['decoder']['message']; |
370 | 370 | |
371 | 371 | if ($value !== null) { |
372 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
372 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
373 | 373 | $value = \imap_utf8($value); |
374 | 374 | if (strpos(strtolower($value), '=?utf-8?') === 0) { |
375 | 375 | $value = mb_decode_mimeheader($value); |
@@ -377,14 +377,14 @@ discard block |
||
377 | 377 | if ($this->notDecoded($original_value, $value)) { |
378 | 378 | $decoded_value = $this->mime_header_decode($value); |
379 | 379 | if (count($decoded_value) > 0) { |
380 | - if(property_exists($decoded_value[0], "text")) { |
|
380 | + if (property_exists($decoded_value[0], "text")) { |
|
381 | 381 | $value = $decoded_value[0]->text; |
382 | 382 | } |
383 | 383 | } |
384 | 384 | } |
385 | - }elseif($decoder === 'iconv') { |
|
385 | + }elseif ($decoder === 'iconv') { |
|
386 | 386 | $value = iconv_mime_decode($value); |
387 | - }else{ |
|
387 | + }else { |
|
388 | 388 | $value = mb_decode_mimeheader($value); |
389 | 389 | } |
390 | 390 | |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * Try to extract the priority from a given raw header string |
405 | 405 | */ |
406 | 406 | private function findPriority() { |
407 | - if(($priority = $this->get("x-priority")) === null) return; |
|
408 | - switch($priority){ |
|
407 | + if (($priority = $this->get("x-priority")) === null) return; |
|
408 | + switch ($priority) { |
|
409 | 409 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
410 | 410 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
411 | 411 | break; |
@@ -437,12 +437,12 @@ discard block |
||
437 | 437 | */ |
438 | 438 | private function decodeAddresses($values) { |
439 | 439 | $addresses = []; |
440 | - foreach($values as $address) { |
|
440 | + foreach ($values as $address) { |
|
441 | 441 | if (preg_match( |
442 | 442 | '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/', |
443 | 443 | $address, |
444 | 444 | $matches |
445 | - )){ |
|
445 | + )) { |
|
446 | 446 | $name = trim(rtrim($matches["name"])); |
447 | 447 | $email = trim(rtrim($matches["email"])); |
448 | 448 | list($mailbox, $host) = array_pad(explode("@", $email), 2, null); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | * @param object $header |
462 | 462 | */ |
463 | 463 | private function extractAddresses($header) { |
464 | - foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){ |
|
464 | + foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) { |
|
465 | 465 | if (property_exists($header, $key)) { |
466 | 466 | $this->attributes[$key] = $this->parseAddresses($header->$key); |
467 | 467 | } |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | } |
493 | 493 | if (!property_exists($address, 'personal')) { |
494 | 494 | $address->personal = false; |
495 | - } else { |
|
495 | + }else { |
|
496 | 496 | $personalParts = $this->mime_header_decode($address->personal); |
497 | 497 | |
498 | - if(is_array($personalParts)) { |
|
498 | + if (is_array($personalParts)) { |
|
499 | 499 | $address->personal = ''; |
500 | 500 | foreach ($personalParts as $p) { |
501 | 501 | $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p)); |
@@ -515,18 +515,18 @@ discard block |
||
515 | 515 | /** |
516 | 516 | * Search and extract potential header extensions |
517 | 517 | */ |
518 | - private function extractHeaderExtensions(){ |
|
518 | + private function extractHeaderExtensions() { |
|
519 | 519 | foreach ($this->attributes as $key => $value) { |
520 | 520 | // Only parse strings and don't parse any attributes like the user-agent |
521 | 521 | if (is_string($value) === true && in_array($key, ["user-agent"]) === false) { |
522 | - if (($pos = strpos($value, ";")) !== false){ |
|
522 | + if (($pos = strpos($value, ";")) !== false) { |
|
523 | 523 | $original = substr($value, 0, $pos); |
524 | 524 | $this->attributes[$key] = trim(rtrim($original)); |
525 | 525 | |
526 | 526 | // Get all potential extensions |
527 | 527 | $extensions = explode(";", substr($value, $pos + 1)); |
528 | - foreach($extensions as $extension) { |
|
529 | - if (($pos = strpos($extension, "=")) !== false){ |
|
528 | + foreach ($extensions as $extension) { |
|
529 | + if (($pos = strpos($extension, "=")) !== false) { |
|
530 | 530 | $key = substr($extension, 0, $pos); |
531 | 531 | $value = substr($extension, $pos + 1); |
532 | 532 | $value = str_replace('"', "", $value); |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | $parsed_date = null; |
564 | 564 | $date = $header->date; |
565 | 565 | |
566 | - if(preg_match('/\+0580/', $date)) { |
|
566 | + if (preg_match('/\+0580/', $date)) { |
|
567 | 567 | $date = str_replace('+0580', '+0530', $date); |
568 | 568 | } |
569 | 569 | |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $date = trim(array_pop($array)); |
587 | 587 | break; |
588 | 588 | } |
589 | - try{ |
|
589 | + try { |
|
590 | 590 | $parsed_date = Carbon::parse($date); |
591 | 591 | } catch (\Exception $_e) { |
592 | 592 | throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e); |