@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false, $sequence = null) { |
203 | 203 | |
204 | 204 | $default_mask = $client->getDefaultMessageMask(); |
205 | - if($default_mask != null) { |
|
205 | + if ($default_mask != null) { |
|
206 | 206 | $this->mask = $default_mask; |
207 | 207 | } |
208 | 208 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | if ($this->sequence === IMAP::ST_UID) { |
228 | 228 | $this->uid = $uid; |
229 | 229 | $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid); |
230 | - }else{ |
|
230 | + }else { |
|
231 | 231 | $this->msgn = $uid; |
232 | 232 | $this->uid = $this->client->getConnection()->getUid($this->msgn); |
233 | 233 | } |
@@ -268,13 +268,13 @@ discard block |
||
268 | 268 | * @throws MessageFlagException |
269 | 269 | * @throws Exceptions\RuntimeException |
270 | 270 | */ |
271 | - public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){ |
|
271 | + public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) { |
|
272 | 272 | $reflection = new \ReflectionClass(self::class); |
273 | 273 | /** @var self $instance */ |
274 | 274 | $instance = $reflection->newInstanceWithoutConstructor(); |
275 | 275 | |
276 | 276 | $default_mask = $client->getDefaultMessageMask(); |
277 | - if($default_mask != null) { |
|
277 | + if ($default_mask != null) { |
|
278 | 278 | $instance->setMask($default_mask); |
279 | 279 | } |
280 | 280 | $instance->setEvents([ |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | if ($instance->getSequence() === IMAP::ST_UID) { |
295 | 295 | $instance->setUid($uid); |
296 | 296 | $instance->setMsglist($msglist); |
297 | - }else{ |
|
297 | + }else { |
|
298 | 298 | $instance->setMsgn($uid, $msglist); |
299 | 299 | } |
300 | 300 | |
@@ -315,13 +315,13 @@ discard block |
||
315 | 315 | * @throws MethodNotFoundException |
316 | 316 | */ |
317 | 317 | public function __call($method, $arguments) { |
318 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
318 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
319 | 319 | $name = Str::snake(substr($method, 3)); |
320 | 320 | return $this->get($name); |
321 | 321 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
322 | 322 | $name = Str::snake(substr($method, 3)); |
323 | 323 | |
324 | - if(in_array($name, array_keys($this->attributes))) { |
|
324 | + if (in_array($name, array_keys($this->attributes))) { |
|
325 | 325 | return $this->__set($name, array_pop($arguments)); |
326 | 326 | } |
327 | 327 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return mixed|null |
361 | 361 | */ |
362 | 362 | public function get($name) { |
363 | - if(isset($this->attributes[$name])) { |
|
363 | + if (isset($this->attributes[$name])) { |
|
364 | 364 | return $this->attributes[$name]; |
365 | 365 | } |
366 | 366 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @throws InvalidMessageDateException |
436 | 436 | */ |
437 | - public function parseRawHeader($raw_header){ |
|
437 | + public function parseRawHeader($raw_header) { |
|
438 | 438 | $this->header = new Header($raw_header); |
439 | 439 | } |
440 | 440 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | public function parseRawFlags($raw_flags) { |
446 | 446 | $this->flags = FlagCollection::make([]); |
447 | 447 | |
448 | - foreach($raw_flags as $flag) { |
|
449 | - if (strpos($flag, "\\") === 0){ |
|
448 | + foreach ($raw_flags as $flag) { |
|
449 | + if (strpos($flag, "\\") === 0) { |
|
450 | 450 | $flag = substr($flag, 1); |
451 | 451 | } |
452 | 452 | $flag_key = strtolower($flag); |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | * @throws Exceptions\EventNotFoundException |
517 | 517 | * @throws MessageFlagException |
518 | 518 | */ |
519 | - public function peek(){ |
|
519 | + public function peek() { |
|
520 | 520 | if ($this->fetch_options == IMAP::FT_PEEK) { |
521 | 521 | if ($this->getFlags()->get("seen") == null) { |
522 | 522 | $this->unsetFlag("Seen"); |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | private function fetchPart(Part $part) { |
564 | 564 | if ($part->isAttachment()) { |
565 | 565 | $this->fetchAttachment($part); |
566 | - }else{ |
|
566 | + }else { |
|
567 | 567 | $encoding = $this->getEncoding($part); |
568 | 568 | |
569 | 569 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) { |
601 | 601 | if ($oAttachment->getId() !== null) { |
602 | 602 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
603 | - } else { |
|
603 | + }else { |
|
604 | 604 | $this->attachments->push($oAttachment); |
605 | 605 | } |
606 | 606 | } |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | |
735 | 735 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
736 | 736 | return @iconv($from, $to.'//IGNORE', $str); |
737 | - } else { |
|
737 | + }else { |
|
738 | 738 | if (!$from) { |
739 | 739 | return mb_convert_encoding($str, $to); |
740 | 740 | } |
@@ -755,9 +755,9 @@ discard block |
||
755 | 755 | return EncodingAliases::get($parameter->value); |
756 | 756 | } |
757 | 757 | } |
758 | - }elseif (property_exists($structure, 'charset')){ |
|
758 | + }elseif (property_exists($structure, 'charset')) { |
|
759 | 759 | return EncodingAliases::get($structure->charset); |
760 | - }elseif (is_string($structure) === true){ |
|
760 | + }elseif (is_string($structure) === true) { |
|
761 | 761 | return mb_detect_encoding($structure); |
762 | 762 | } |
763 | 763 | |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | * @throws Exceptions\ConnectionFailedException |
772 | 772 | * @throws Exceptions\FolderFetchingException |
773 | 773 | */ |
774 | - public function getFolder(){ |
|
774 | + public function getFolder() { |
|
775 | 775 | return $this->client->getFolder($this->folder_path); |
776 | 776 | } |
777 | 777 | |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | * @throws Exceptions\FolderFetchingException |
787 | 787 | * @throws Exceptions\GetMessagesFailedException |
788 | 788 | */ |
789 | - public function thread($sent_folder = null, &$thread = null, $folder = null){ |
|
789 | + public function thread($sent_folder = null, &$thread = null, $folder = null) { |
|
790 | 790 | $thread = $thread ? $thread : MessageCollection::make([]); |
791 | - $folder = $folder ? $folder : $this->getFolder(); |
|
791 | + $folder = $folder ? $folder : $this->getFolder(); |
|
792 | 792 | $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent")); |
793 | 793 | |
794 | 794 | /** @var Message $message */ |
795 | - foreach($thread as $message) { |
|
795 | + foreach ($thread as $message) { |
|
796 | 796 | if ($message->message_id == $this->message_id) { |
797 | 797 | return $thread; |
798 | 798 | } |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder); |
804 | 804 | |
805 | 805 | if (is_array($this->in_reply_to)) { |
806 | - foreach($this->in_reply_to as $in_reply_to) { |
|
806 | + foreach ($this->in_reply_to as $in_reply_to) { |
|
807 | 807 | $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder); |
808 | 808 | $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder); |
809 | 809 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | * @throws Exceptions\ConnectionFailedException |
824 | 824 | * @throws Exceptions\GetMessagesFailedException |
825 | 825 | */ |
826 | - protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){ |
|
826 | + protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder) { |
|
827 | 827 | $primary_folder->query()->inReplyTo($in_reply_to) |
828 | 828 | ->setFetchBody($this->getFetchBodyOption()) |
829 | 829 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * @throws Exceptions\ConnectionFailedException |
844 | 844 | * @throws Exceptions\GetMessagesFailedException |
845 | 845 | */ |
846 | - protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){ |
|
846 | + protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder) { |
|
847 | 847 | $primary_folder->query()->messageId($message_id) |
848 | 848 | ->setFetchBody($this->getFetchBodyOption()) |
849 | 849 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -936,14 +936,14 @@ discard block |
||
936 | 936 | * @throws MessageFlagException |
937 | 937 | * @throws MessageHeaderFetchingException |
938 | 938 | */ |
939 | - protected function fetchNewMail($folder, $next_uid, $event, $expunge){ |
|
940 | - if($expunge) $this->client->expunge(); |
|
939 | + protected function fetchNewMail($folder, $next_uid, $event, $expunge) { |
|
940 | + if ($expunge) $this->client->expunge(); |
|
941 | 941 | |
942 | 942 | $this->client->openFolder($folder->path); |
943 | 943 | |
944 | 944 | if ($this->sequence === IMAP::ST_UID) { |
945 | 945 | $sequence_id = $next_uid; |
946 | - }else{ |
|
946 | + }else { |
|
947 | 947 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
948 | 948 | } |
949 | 949 | |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | */ |
966 | 966 | public function delete($expunge = true) { |
967 | 967 | $status = $this->setFlag("Deleted"); |
968 | - if($expunge) $this->client->expunge(); |
|
968 | + if ($expunge) $this->client->expunge(); |
|
969 | 969 | |
970 | 970 | $event = $this->getEvent("message", "deleted"); |
971 | 971 | $event::dispatch($this); |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | */ |
985 | 985 | public function restore($expunge = true) { |
986 | 986 | $status = $this->unsetFlag("Deleted"); |
987 | - if($expunge) $this->client->expunge(); |
|
987 | + if ($expunge) $this->client->expunge(); |
|
988 | 988 | |
989 | 989 | $event = $this->getEvent("message", "restored"); |
990 | 990 | $event::dispatch($this); |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | * |
1086 | 1086 | * @return AttachmentCollection |
1087 | 1087 | */ |
1088 | - public function attachments(){ |
|
1088 | + public function attachments() { |
|
1089 | 1089 | return $this->getAttachments(); |
1090 | 1090 | } |
1091 | 1091 | |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | * |
1183 | 1183 | * @return FlagCollection |
1184 | 1184 | */ |
1185 | - public function flags(){ |
|
1185 | + public function flags() { |
|
1186 | 1186 | return $this->getFlags(); |
1187 | 1187 | } |
1188 | 1188 | |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | * |
1192 | 1192 | * @return Structure|null |
1193 | 1193 | */ |
1194 | - public function getStructure(){ |
|
1194 | + public function getStructure() { |
|
1195 | 1195 | return $this->structure; |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | * |
1218 | 1218 | * @return array |
1219 | 1219 | */ |
1220 | - public function getAttributes(){ |
|
1220 | + public function getAttributes() { |
|
1221 | 1221 | return array_merge($this->attributes, $this->header->getAttributes()); |
1222 | 1222 | } |
1223 | 1223 | |
@@ -1227,8 +1227,8 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * @return $this |
1229 | 1229 | */ |
1230 | - public function setMask($mask){ |
|
1231 | - if(class_exists($mask)){ |
|
1230 | + public function setMask($mask) { |
|
1231 | + if (class_exists($mask)) { |
|
1232 | 1232 | $this->mask = $mask; |
1233 | 1233 | } |
1234 | 1234 | |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | * |
1241 | 1241 | * @return string |
1242 | 1242 | */ |
1243 | - public function getMask(){ |
|
1243 | + public function getMask() { |
|
1244 | 1244 | return $this->mask; |
1245 | 1245 | } |
1246 | 1246 | |
@@ -1251,9 +1251,9 @@ discard block |
||
1251 | 1251 | * @return mixed |
1252 | 1252 | * @throws MaskNotFoundException |
1253 | 1253 | */ |
1254 | - public function mask($mask = null){ |
|
1254 | + public function mask($mask = null) { |
|
1255 | 1255 | $mask = $mask !== null ? $mask : $this->mask; |
1256 | - if(class_exists($mask)){ |
|
1256 | + if (class_exists($mask)) { |
|
1257 | 1257 | return new $mask($this); |
1258 | 1258 | } |
1259 | 1259 | |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | * |
1267 | 1267 | * @return $this |
1268 | 1268 | */ |
1269 | - public function setFolderPath($folder_path){ |
|
1269 | + public function setFolderPath($folder_path) { |
|
1270 | 1270 | $this->folder_path = $folder_path; |
1271 | 1271 | |
1272 | 1272 | return $this; |
@@ -1278,7 +1278,7 @@ discard block |
||
1278 | 1278 | * |
1279 | 1279 | * @return $this |
1280 | 1280 | */ |
1281 | - public function setConfig($config){ |
|
1281 | + public function setConfig($config) { |
|
1282 | 1282 | $this->config = $config; |
1283 | 1283 | |
1284 | 1284 | return $this; |
@@ -1290,7 +1290,7 @@ discard block |
||
1290 | 1290 | * |
1291 | 1291 | * @return $this |
1292 | 1292 | */ |
1293 | - public function setAvailableFlags($available_flags){ |
|
1293 | + public function setAvailableFlags($available_flags) { |
|
1294 | 1294 | $this->available_flags = $available_flags; |
1295 | 1295 | |
1296 | 1296 | return $this; |
@@ -1302,7 +1302,7 @@ discard block |
||
1302 | 1302 | * |
1303 | 1303 | * @return $this |
1304 | 1304 | */ |
1305 | - public function setAttachments($attachments){ |
|
1305 | + public function setAttachments($attachments) { |
|
1306 | 1306 | $this->attachments = $attachments; |
1307 | 1307 | |
1308 | 1308 | return $this; |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | * |
1315 | 1315 | * @return $this |
1316 | 1316 | */ |
1317 | - public function setFlags($flags){ |
|
1317 | + public function setFlags($flags) { |
|
1318 | 1318 | $this->flags = $flags; |
1319 | 1319 | |
1320 | 1320 | return $this; |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | * @throws Exceptions\ConnectionFailedException |
1328 | 1328 | * @return $this |
1329 | 1329 | */ |
1330 | - public function setClient($client){ |
|
1330 | + public function setClient($client) { |
|
1331 | 1331 | $this->client = $client; |
1332 | 1332 | $this->client->openFolder($this->folder_path); |
1333 | 1333 | |
@@ -1342,7 +1342,7 @@ discard block |
||
1342 | 1342 | * @throws Exceptions\RuntimeException |
1343 | 1343 | * @return $this |
1344 | 1344 | */ |
1345 | - public function setUid($uid){ |
|
1345 | + public function setUid($uid) { |
|
1346 | 1346 | $this->uid = $uid; |
1347 | 1347 | $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid); |
1348 | 1348 | $this->msglist = null; |
@@ -1359,7 +1359,7 @@ discard block |
||
1359 | 1359 | * @throws Exceptions\RuntimeException |
1360 | 1360 | * @return $this |
1361 | 1361 | */ |
1362 | - public function setMsgn($msgn, $msglist = null){ |
|
1362 | + public function setMsgn($msgn, $msglist = null) { |
|
1363 | 1363 | $this->msgn = $msgn; |
1364 | 1364 | $this->msglist = $msglist; |
1365 | 1365 | $this->uid = $this->client->getConnection()->getUid($this->msgn); |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | * |
1373 | 1373 | * @return int |
1374 | 1374 | */ |
1375 | - public function getSequence(){ |
|
1375 | + public function getSequence() { |
|
1376 | 1376 | return $this->sequence; |
1377 | 1377 | } |
1378 | 1378 | |
@@ -1381,7 +1381,7 @@ discard block |
||
1381 | 1381 | * |
1382 | 1382 | * @return int |
1383 | 1383 | */ |
1384 | - public function getSequenceId(){ |
|
1384 | + public function getSequenceId() { |
|
1385 | 1385 | return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn; |
1386 | 1386 | } |
1387 | 1387 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | if ($this->sequence === IMAP::ST_UID) { |
228 | 228 | $this->uid = $uid; |
229 | 229 | $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid); |
230 | - }else{ |
|
230 | + } else{ |
|
231 | 231 | $this->msgn = $uid; |
232 | 232 | $this->uid = $this->client->getConnection()->getUid($this->msgn); |
233 | 233 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | if ($instance->getSequence() === IMAP::ST_UID) { |
295 | 295 | $instance->setUid($uid); |
296 | 296 | $instance->setMsglist($msglist); |
297 | - }else{ |
|
297 | + } else{ |
|
298 | 298 | $instance->setMsgn($uid, $msglist); |
299 | 299 | } |
300 | 300 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | if(strtolower(substr($method, 0, 3)) === 'get') { |
319 | 319 | $name = Str::snake(substr($method, 3)); |
320 | 320 | return $this->get($name); |
321 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
321 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
322 | 322 | $name = Str::snake(substr($method, 3)); |
323 | 323 | |
324 | 324 | if(in_array($name, array_keys($this->attributes))) { |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | if ($this->getFlags()->get("seen") == null) { |
522 | 522 | $this->unsetFlag("Seen"); |
523 | 523 | } |
524 | - }elseif ($this->getFlags()->get("seen") != null) { |
|
524 | + } elseif ($this->getFlags()->get("seen") != null) { |
|
525 | 525 | $this->setFlag("Seen"); |
526 | 526 | } |
527 | 527 | } |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | private function fetchPart(Part $part) { |
564 | 564 | if ($part->isAttachment()) { |
565 | 565 | $this->fetchAttachment($part); |
566 | - }else{ |
|
566 | + } else{ |
|
567 | 567 | $encoding = $this->getEncoding($part); |
568 | 568 | |
569 | 569 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -755,9 +755,9 @@ discard block |
||
755 | 755 | return EncodingAliases::get($parameter->value); |
756 | 756 | } |
757 | 757 | } |
758 | - }elseif (property_exists($structure, 'charset')){ |
|
758 | + } elseif (property_exists($structure, 'charset')){ |
|
759 | 759 | return EncodingAliases::get($structure->charset); |
760 | - }elseif (is_string($structure) === true){ |
|
760 | + } elseif (is_string($structure) === true){ |
|
761 | 761 | return mb_detect_encoding($structure); |
762 | 762 | } |
763 | 763 | |
@@ -937,13 +937,15 @@ discard block |
||
937 | 937 | * @throws MessageHeaderFetchingException |
938 | 938 | */ |
939 | 939 | protected function fetchNewMail($folder, $next_uid, $event, $expunge){ |
940 | - if($expunge) $this->client->expunge(); |
|
940 | + if($expunge) { |
|
941 | + $this->client->expunge(); |
|
942 | + } |
|
941 | 943 | |
942 | 944 | $this->client->openFolder($folder->path); |
943 | 945 | |
944 | 946 | if ($this->sequence === IMAP::ST_UID) { |
945 | 947 | $sequence_id = $next_uid; |
946 | - }else{ |
|
948 | + } else{ |
|
947 | 949 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
948 | 950 | } |
949 | 951 | |
@@ -965,7 +967,9 @@ discard block |
||
965 | 967 | */ |
966 | 968 | public function delete($expunge = true) { |
967 | 969 | $status = $this->setFlag("Deleted"); |
968 | - if($expunge) $this->client->expunge(); |
|
970 | + if($expunge) { |
|
971 | + $this->client->expunge(); |
|
972 | + } |
|
969 | 973 | |
970 | 974 | $event = $this->getEvent("message", "deleted"); |
971 | 975 | $event::dispatch($this); |
@@ -984,7 +988,9 @@ discard block |
||
984 | 988 | */ |
985 | 989 | public function restore($expunge = true) { |
986 | 990 | $status = $this->unsetFlag("Deleted"); |
987 | - if($expunge) $this->client->expunge(); |
|
991 | + if($expunge) { |
|
992 | + $this->client->expunge(); |
|
993 | + } |
|
988 | 994 | |
989 | 995 | $event = $this->getEvent("message", "restored"); |
990 | 996 | $event::dispatch($this); |