@@ -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"); |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | * @throws MessageFlagException |
262 | 262 | * @throws Exceptions\RuntimeException |
263 | 263 | */ |
264 | - public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){ |
|
264 | + public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) { |
|
265 | 265 | $reflection = new \ReflectionClass(self::class); |
266 | 266 | /** @var self $instance */ |
267 | 267 | $instance = $reflection->newInstanceWithoutConstructor(); |
268 | 268 | |
269 | 269 | $default_mask = $client->getDefaultMessageMask(); |
270 | - if($default_mask != null) { |
|
270 | + if ($default_mask != null) { |
|
271 | 271 | $instance->setMask($default_mask); |
272 | 272 | } |
273 | 273 | $instance->setEvents([ |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | * @throws MethodNotFoundException |
303 | 303 | */ |
304 | 304 | public function __call($method, $arguments) { |
305 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
305 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
306 | 306 | $name = Str::snake(substr($method, 3)); |
307 | 307 | return $this->get($name); |
308 | 308 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
309 | 309 | $name = Str::snake(substr($method, 3)); |
310 | 310 | |
311 | - if(in_array($name, array_keys($this->attributes))) { |
|
311 | + if (in_array($name, array_keys($this->attributes))) { |
|
312 | 312 | return $this->__set($name, array_pop($arguments)); |
313 | 313 | } |
314 | 314 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * @return mixed|null |
348 | 348 | */ |
349 | 349 | public function get($name) { |
350 | - if(isset($this->attributes[$name])) { |
|
350 | + if (isset($this->attributes[$name])) { |
|
351 | 351 | return $this->attributes[$name]; |
352 | 352 | } |
353 | 353 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @throws InvalidMessageDateException |
423 | 423 | */ |
424 | - public function parseRawHeader($raw_header){ |
|
424 | + public function parseRawHeader($raw_header) { |
|
425 | 425 | $this->header = new Header($raw_header); |
426 | 426 | } |
427 | 427 | |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | public function parseRawFlags($raw_flags) { |
433 | 433 | $this->flags = FlagCollection::make([]); |
434 | 434 | |
435 | - foreach($raw_flags as $flag) { |
|
436 | - if (strpos($flag, "\\") === 0){ |
|
435 | + foreach ($raw_flags as $flag) { |
|
436 | + if (strpos($flag, "\\") === 0) { |
|
437 | 437 | $flag = substr($flag, 1); |
438 | 438 | } |
439 | 439 | $flag_key = strtolower($flag); |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @throws MessageFlagException |
507 | 507 | * @throws Exceptions\RuntimeException |
508 | 508 | */ |
509 | - public function peek(){ |
|
509 | + public function peek() { |
|
510 | 510 | if ($this->fetch_options == IMAP::FT_PEEK) { |
511 | 511 | if ($this->getFlags()->get("seen") == null) { |
512 | 512 | $this->unsetFlag("Seen"); |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | private function fetchPart(Part $part) { |
556 | 556 | if ($part->isAttachment()) { |
557 | 557 | $this->fetchAttachment($part); |
558 | - }else{ |
|
558 | + }else { |
|
559 | 559 | $encoding = $this->getEncoding($part); |
560 | 560 | |
561 | 561 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) { |
593 | 593 | if ($oAttachment->getId() !== null) { |
594 | 594 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
595 | - } else { |
|
595 | + }else { |
|
596 | 596 | $this->attachments->push($oAttachment); |
597 | 597 | } |
598 | 598 | } |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | |
727 | 727 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
728 | 728 | return @iconv($from, $to.'//IGNORE', $str); |
729 | - } else { |
|
729 | + }else { |
|
730 | 730 | if (!$from) { |
731 | 731 | return mb_convert_encoding($str, $to); |
732 | 732 | } |
@@ -747,9 +747,9 @@ discard block |
||
747 | 747 | return EncodingAliases::get($parameter->value); |
748 | 748 | } |
749 | 749 | } |
750 | - }elseif (property_exists($structure, 'charset')){ |
|
750 | + }elseif (property_exists($structure, 'charset')) { |
|
751 | 751 | return EncodingAliases::get($structure->charset); |
752 | - }elseif (is_string($structure) === true){ |
|
752 | + }elseif (is_string($structure) === true) { |
|
753 | 753 | return mb_detect_encoding($structure); |
754 | 754 | } |
755 | 755 | |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | * @throws Exceptions\FolderFetchingException |
765 | 765 | * @throws Exceptions\RuntimeException |
766 | 766 | */ |
767 | - public function getFolder(){ |
|
767 | + public function getFolder() { |
|
768 | 768 | return $this->client->getFolder($this->folder_path); |
769 | 769 | } |
770 | 770 | |
@@ -780,13 +780,13 @@ discard block |
||
780 | 780 | * @throws Exceptions\GetMessagesFailedException |
781 | 781 | * @throws Exceptions\RuntimeException |
782 | 782 | */ |
783 | - public function thread($sent_folder = null, &$thread = null, $folder = null){ |
|
783 | + public function thread($sent_folder = null, &$thread = null, $folder = null) { |
|
784 | 784 | $thread = $thread ? $thread : MessageCollection::make([]); |
785 | - $folder = $folder ? $folder : $this->getFolder(); |
|
785 | + $folder = $folder ? $folder : $this->getFolder(); |
|
786 | 786 | $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent")); |
787 | 787 | |
788 | 788 | /** @var Message $message */ |
789 | - foreach($thread as $message) { |
|
789 | + foreach ($thread as $message) { |
|
790 | 790 | if ($message->message_id == $this->message_id) { |
791 | 791 | return $thread; |
792 | 792 | } |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder); |
798 | 798 | |
799 | 799 | if (is_array($this->in_reply_to)) { |
800 | - foreach($this->in_reply_to as $in_reply_to) { |
|
800 | + foreach ($this->in_reply_to as $in_reply_to) { |
|
801 | 801 | $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder); |
802 | 802 | $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder); |
803 | 803 | } |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | * @throws Exceptions\GetMessagesFailedException |
819 | 819 | * @throws Exceptions\RuntimeException |
820 | 820 | */ |
821 | - protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){ |
|
821 | + protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder) { |
|
822 | 822 | $primary_folder->query()->inReplyTo($in_reply_to) |
823 | 823 | ->setFetchBody($this->getFetchBodyOption()) |
824 | 824 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | * @throws Exceptions\GetMessagesFailedException |
840 | 840 | * @throws Exceptions\RuntimeException |
841 | 841 | */ |
842 | - protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){ |
|
842 | + protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder) { |
|
843 | 843 | $primary_folder->query()->messageId($message_id) |
844 | 844 | ->setFetchBody($this->getFetchBodyOption()) |
845 | 845 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -932,14 +932,14 @@ discard block |
||
932 | 932 | * @throws MessageFlagException |
933 | 933 | * @throws MessageHeaderFetchingException |
934 | 934 | */ |
935 | - protected function fetchNewMail($folder, $next_uid, $event, $expunge){ |
|
936 | - if($expunge) $this->client->expunge(); |
|
935 | + protected function fetchNewMail($folder, $next_uid, $event, $expunge) { |
|
936 | + if ($expunge) $this->client->expunge(); |
|
937 | 937 | |
938 | 938 | $this->client->openFolder($folder->path); |
939 | 939 | |
940 | 940 | if ($this->sequence === IMAP::ST_UID) { |
941 | 941 | $sequence_id = $next_uid; |
942 | - }else{ |
|
942 | + }else { |
|
943 | 943 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
944 | 944 | } |
945 | 945 | |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | */ |
963 | 963 | public function delete($expunge = true) { |
964 | 964 | $status = $this->setFlag("Deleted"); |
965 | - if($expunge) $this->client->expunge(); |
|
965 | + if ($expunge) $this->client->expunge(); |
|
966 | 966 | |
967 | 967 | $event = $this->getEvent("message", "deleted"); |
968 | 968 | $event::dispatch($this); |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | */ |
983 | 983 | public function restore($expunge = true) { |
984 | 984 | $status = $this->unsetFlag("Deleted"); |
985 | - if($expunge) $this->client->expunge(); |
|
985 | + if ($expunge) $this->client->expunge(); |
|
986 | 986 | |
987 | 987 | $event = $this->getEvent("message", "restored"); |
988 | 988 | $event::dispatch($this); |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | * |
1088 | 1088 | * @return AttachmentCollection |
1089 | 1089 | */ |
1090 | - public function attachments(){ |
|
1090 | + public function attachments() { |
|
1091 | 1091 | return $this->getAttachments(); |
1092 | 1092 | } |
1093 | 1093 | |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | * |
1186 | 1186 | * @return FlagCollection |
1187 | 1187 | */ |
1188 | - public function flags(){ |
|
1188 | + public function flags() { |
|
1189 | 1189 | return $this->getFlags(); |
1190 | 1190 | } |
1191 | 1191 | |
@@ -1194,7 +1194,7 @@ discard block |
||
1194 | 1194 | * |
1195 | 1195 | * @return Structure|null |
1196 | 1196 | */ |
1197 | - public function getStructure(){ |
|
1197 | + public function getStructure() { |
|
1198 | 1198 | return $this->structure; |
1199 | 1199 | } |
1200 | 1200 | |
@@ -1220,7 +1220,7 @@ discard block |
||
1220 | 1220 | * |
1221 | 1221 | * @return array |
1222 | 1222 | */ |
1223 | - public function getAttributes(){ |
|
1223 | + public function getAttributes() { |
|
1224 | 1224 | return array_merge($this->attributes, $this->header->getAttributes()); |
1225 | 1225 | } |
1226 | 1226 | |
@@ -1230,8 +1230,8 @@ discard block |
||
1230 | 1230 | * |
1231 | 1231 | * @return $this |
1232 | 1232 | */ |
1233 | - public function setMask($mask){ |
|
1234 | - if(class_exists($mask)){ |
|
1233 | + public function setMask($mask) { |
|
1234 | + if (class_exists($mask)) { |
|
1235 | 1235 | $this->mask = $mask; |
1236 | 1236 | } |
1237 | 1237 | |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | * |
1244 | 1244 | * @return string |
1245 | 1245 | */ |
1246 | - public function getMask(){ |
|
1246 | + public function getMask() { |
|
1247 | 1247 | return $this->mask; |
1248 | 1248 | } |
1249 | 1249 | |
@@ -1254,9 +1254,9 @@ discard block |
||
1254 | 1254 | * @return mixed |
1255 | 1255 | * @throws MaskNotFoundException |
1256 | 1256 | */ |
1257 | - public function mask($mask = null){ |
|
1257 | + public function mask($mask = null) { |
|
1258 | 1258 | $mask = $mask !== null ? $mask : $this->mask; |
1259 | - if(class_exists($mask)){ |
|
1259 | + if (class_exists($mask)) { |
|
1260 | 1260 | return new $mask($this); |
1261 | 1261 | } |
1262 | 1262 | |
@@ -1269,7 +1269,7 @@ discard block |
||
1269 | 1269 | * |
1270 | 1270 | * @return $this |
1271 | 1271 | */ |
1272 | - public function setFolderPath($folder_path){ |
|
1272 | + public function setFolderPath($folder_path) { |
|
1273 | 1273 | $this->folder_path = $folder_path; |
1274 | 1274 | |
1275 | 1275 | return $this; |
@@ -1281,7 +1281,7 @@ discard block |
||
1281 | 1281 | * |
1282 | 1282 | * @return $this |
1283 | 1283 | */ |
1284 | - public function setConfig($config){ |
|
1284 | + public function setConfig($config) { |
|
1285 | 1285 | $this->config = $config; |
1286 | 1286 | |
1287 | 1287 | return $this; |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | * |
1294 | 1294 | * @return $this |
1295 | 1295 | */ |
1296 | - public function setAvailableFlags($available_flags){ |
|
1296 | + public function setAvailableFlags($available_flags) { |
|
1297 | 1297 | $this->available_flags = $available_flags; |
1298 | 1298 | |
1299 | 1299 | return $this; |
@@ -1305,7 +1305,7 @@ discard block |
||
1305 | 1305 | * |
1306 | 1306 | * @return $this |
1307 | 1307 | */ |
1308 | - public function setAttachments($attachments){ |
|
1308 | + public function setAttachments($attachments) { |
|
1309 | 1309 | $this->attachments = $attachments; |
1310 | 1310 | |
1311 | 1311 | return $this; |
@@ -1317,7 +1317,7 @@ discard block |
||
1317 | 1317 | * |
1318 | 1318 | * @return $this |
1319 | 1319 | */ |
1320 | - public function setFlags($flags){ |
|
1320 | + public function setFlags($flags) { |
|
1321 | 1321 | $this->flags = $flags; |
1322 | 1322 | |
1323 | 1323 | return $this; |
@@ -1331,7 +1331,7 @@ discard block |
||
1331 | 1331 | * @throws Exceptions\RuntimeException |
1332 | 1332 | * @throws Exceptions\ConnectionFailedException |
1333 | 1333 | */ |
1334 | - public function setClient($client){ |
|
1334 | + public function setClient($client) { |
|
1335 | 1335 | $this->client = $client; |
1336 | 1336 | $this->client->openFolder($this->folder_path); |
1337 | 1337 | |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | * @throws Exceptions\RuntimeException |
1347 | 1347 | * @return $this |
1348 | 1348 | */ |
1349 | - public function setUid($uid){ |
|
1349 | + public function setUid($uid) { |
|
1350 | 1350 | $this->uid = $uid; |
1351 | 1351 | $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid); |
1352 | 1352 | $this->msglist = null; |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | * @throws Exceptions\RuntimeException |
1364 | 1364 | * @return $this |
1365 | 1365 | */ |
1366 | - public function setMsgn($msgn, $msglist = null){ |
|
1366 | + public function setMsgn($msgn, $msglist = null) { |
|
1367 | 1367 | $this->msgn = $msgn; |
1368 | 1368 | $this->msglist = $msglist; |
1369 | 1369 | $this->uid = $this->client->getConnection()->getUid($this->msgn); |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | * |
1377 | 1377 | * @return int |
1378 | 1378 | */ |
1379 | - public function getSequence(){ |
|
1379 | + public function getSequence() { |
|
1380 | 1380 | return $this->sequence; |
1381 | 1381 | } |
1382 | 1382 | |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | * |
1386 | 1386 | * @return int |
1387 | 1387 | */ |
1388 | - public function getSequenceId(){ |
|
1388 | + public function getSequenceId() { |
|
1389 | 1389 | return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn; |
1390 | 1390 | } |
1391 | 1391 | |
@@ -1397,11 +1397,11 @@ discard block |
||
1397 | 1397 | * @throws Exceptions\ConnectionFailedException |
1398 | 1398 | * @throws Exceptions\RuntimeException |
1399 | 1399 | */ |
1400 | - public function setSequenceId($uid, $msglist = null){ |
|
1400 | + public function setSequenceId($uid, $msglist = null) { |
|
1401 | 1401 | if ($this->getSequence() === IMAP::ST_UID) { |
1402 | 1402 | $this->setUid($uid); |
1403 | 1403 | $this->setMsglist($msglist); |
1404 | - }else{ |
|
1404 | + }else { |
|
1405 | 1405 | $this->setMsgn($uid, $msglist); |
1406 | 1406 | } |
1407 | 1407 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | $this->setDelimiter($delimiter); |
127 | 127 | $this->path = $folder_name; |
128 | - $this->full_name = $this->decodeName($folder_name); |
|
128 | + $this->full_name = $this->decodeName($folder_name); |
|
129 | 129 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
130 | 130 | |
131 | 131 | $this->parseAttributes($attributes); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @throws Exceptions\ConnectionFailedException |
140 | 140 | * @throws Exceptions\RuntimeException |
141 | 141 | */ |
142 | - public function query($charset = 'UTF-8'){ |
|
142 | + public function query($charset = 'UTF-8') { |
|
143 | 143 | $this->getClient()->checkConnection(); |
144 | 144 | $this->getClient()->openFolder($this->path); |
145 | 145 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @throws Exceptions\ConnectionFailedException |
152 | 152 | * @throws Exceptions\RuntimeException |
153 | 153 | */ |
154 | - public function search($charset = 'UTF-8'){ |
|
154 | + public function search($charset = 'UTF-8') { |
|
155 | 155 | return $this->query($charset); |
156 | 156 | } |
157 | 157 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @throws Exceptions\ConnectionFailedException |
161 | 161 | * @throws Exceptions\RuntimeException |
162 | 162 | */ |
163 | - public function messages($charset = 'UTF-8'){ |
|
163 | + public function messages($charset = 'UTF-8') { |
|
164 | 164 | return $this->query($charset); |
165 | 165 | } |
166 | 166 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | public function move($new_name, $expunge = true) { |
236 | 236 | $this->client->checkConnection(); |
237 | 237 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
238 | - if($expunge) $this->client->expunge(); |
|
238 | + if ($expunge) $this->client->expunge(); |
|
239 | 239 | |
240 | 240 | $folder = $this->client->getFolder($new_name); |
241 | 241 | $event = $this->getEvent("folder", "moved"); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @throws ConnectionFailedException |
253 | 253 | * @throws Exceptions\RuntimeException |
254 | 254 | */ |
255 | - public function overview($sequence = null){ |
|
255 | + public function overview($sequence = null) { |
|
256 | 256 | $this->client->openFolder($this->path); |
257 | 257 | $sequence = $sequence === null ? "1:*" : $sequence; |
258 | 258 | $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | |
279 | 279 | if ($internal_date != null) { |
280 | - if ($internal_date instanceof Carbon){ |
|
280 | + if ($internal_date instanceof Carbon) { |
|
281 | 281 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
282 | 282 | } |
283 | 283 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function delete($expunge = true) { |
313 | 313 | $status = $this->client->getConnection()->deleteFolder($this->path); |
314 | - if($expunge) $this->client->expunge(); |
|
314 | + if ($expunge) $this->client->expunge(); |
|
315 | 315 | |
316 | 316 | $event = $this->getEvent("folder", "deleted"); |
317 | 317 | $event::dispatch($this); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | try { |
371 | 371 | $line = $connection->nextLine(); |
372 | 372 | if (($pos = strpos($line, "EXISTS")) !== false) { |
373 | - $msgn = (int) substr($line, 2, $pos -2); |
|
373 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
374 | 374 | $connection->done(); |
375 | 375 | |
376 | 376 | $this->client->openFolder($this->path, true); |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | |
384 | 384 | $connection->idle(); |
385 | 385 | } |
386 | - }catch (Exceptions\RuntimeException $e) { |
|
387 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
386 | + } catch (Exceptions\RuntimeException $e) { |
|
387 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
388 | 388 | throw $e; |
389 | 389 | } |
390 | 390 | } |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | * Set the delimiter |
427 | 427 | * @param $delimiter |
428 | 428 | */ |
429 | - public function setDelimiter($delimiter){ |
|
430 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
429 | + public function setDelimiter($delimiter) { |
|
430 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
431 | 431 | $delimiter = ClientManager::get('options.delimiter', '/'); |
432 | 432 | } |
433 | 433 |