Passed
Push — master ( 1aebda...1972a3 )
by Malte
02:24
created
src/Message.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false, $sequence = null) {
205 205
 
206 206
         $default_mask = $client->getDefaultMessageMask();
207
-        if($default_mask != null) {
207
+        if ($default_mask != null) {
208 208
             $this->mask = $default_mask;
209 209
         }
210 210
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
      * @throws MessageFlagException
264 264
      * @throws Exceptions\RuntimeException
265 265
      */
266
-    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){
266
+    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) {
267 267
         $reflection = new ReflectionClass(self::class);
268 268
         /** @var self $instance */
269 269
         $instance = $reflection->newInstanceWithoutConstructor();
270 270
 
271 271
         $default_mask = $client->getDefaultMessageMask();
272
-        if($default_mask != null) {
272
+        if ($default_mask != null) {
273 273
             $instance->setMask($default_mask);
274 274
         }
275 275
         $instance->setEvents([
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
      * @throws MethodNotFoundException
305 305
      */
306 306
     public function __call($method, $arguments) {
307
-        if(strtolower(substr($method, 0, 3)) === 'get') {
307
+        if (strtolower(substr($method, 0, 3)) === 'get') {
308 308
             $name = Str::snake(substr($method, 3));
309 309
             return $this->get($name);
310 310
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
311 311
             $name = Str::snake(substr($method, 3));
312 312
 
313
-            if(in_array($name, array_keys($this->attributes))) {
313
+            if (in_array($name, array_keys($this->attributes))) {
314 314
                 return $this->__set($name, array_pop($arguments));
315 315
             }
316 316
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
      * @return mixed|null
350 350
      */
351 351
     public function get($name) {
352
-        if(isset($this->attributes[$name])) {
352
+        if (isset($this->attributes[$name])) {
353 353
             return $this->attributes[$name];
354 354
         }
355 355
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
      *
424 424
      * @throws InvalidMessageDateException
425 425
      */
426
-    public function parseRawHeader($raw_header){
426
+    public function parseRawHeader($raw_header) {
427 427
         $this->header = new Header($raw_header);
428 428
     }
429 429
 
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
     public function parseRawFlags($raw_flags) {
435 435
         $this->flags = FlagCollection::make([]);
436 436
 
437
-        foreach($raw_flags as $flag) {
438
-            if (strpos($flag, "\\") === 0){
437
+        foreach ($raw_flags as $flag) {
438
+            if (strpos($flag, "\\") === 0) {
439 439
                 $flag = substr($flag, 1);
440 440
             }
441 441
             $flag_key = strtolower($flag);
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
      * @throws MessageFlagException
509 509
      * @throws Exceptions\RuntimeException
510 510
      */
511
-    public function peek(){
511
+    public function peek() {
512 512
         if ($this->fetch_options == IMAP::FT_PEEK) {
513 513
             if ($this->getFlags()->get("seen") == null) {
514 514
                 $this->unsetFlag("Seen");
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
     private function fetchPart(Part $part) {
558 558
         if ($part->isAttachment()) {
559 559
             $this->fetchAttachment($part);
560
-        }else{
560
+        }else {
561 561
             $encoding = $this->getEncoding($part);
562 562
 
563 563
             $content = $this->decodeString($part->content, $part->encoding);
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 
583 583
             if (isset($this->bodies[$subtype])) {
584 584
                 $this->bodies[$subtype] .= "\n".$content;
585
-            }else{
585
+            }else {
586 586
                 $this->bodies[$subtype] = $content;
587 587
             }
588 588
         }
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
         if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) {
599 599
             if ($oAttachment->getId() !== null) {
600 600
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
601
-            } else {
601
+            }else {
602 602
                 $this->attachments->push($oAttachment);
603 603
             }
604 604
         }
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 
733 733
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
734 734
             return @iconv($from, $to.'//IGNORE', $str);
735
-        } else {
735
+        }else {
736 736
             if (!$from) {
737 737
                 return mb_convert_encoding($str, $to);
738 738
             }
@@ -753,9 +753,9 @@  discard block
 block discarded – undo
753 753
                     return EncodingAliases::get($parameter->value);
754 754
                 }
755 755
             }
756
-        }elseif (property_exists($structure, 'charset')){
756
+        }elseif (property_exists($structure, 'charset')) {
757 757
             return EncodingAliases::get($structure->charset);
758
-        }elseif (is_string($structure) === true){
758
+        }elseif (is_string($structure) === true) {
759 759
             return mb_detect_encoding($structure);
760 760
         }
761 761
 
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
      * @throws Exceptions\FolderFetchingException
771 771
      * @throws Exceptions\RuntimeException
772 772
      */
773
-    public function getFolder(){
773
+    public function getFolder() {
774 774
         return $this->client->getFolder($this->folder_path);
775 775
     }
776 776
 
@@ -786,13 +786,13 @@  discard block
 block discarded – undo
786 786
      * @throws Exceptions\GetMessagesFailedException
787 787
      * @throws Exceptions\RuntimeException
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
 block discarded – undo
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
             }
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
      * @throws Exceptions\GetMessagesFailedException
825 825
      * @throws Exceptions\RuntimeException
826 826
      */
827
-    protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){
827
+    protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder) {
828 828
         $primary_folder->query()->inReplyTo($in_reply_to)
829 829
         ->setFetchBody($this->getFetchBodyOption())
830 830
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
      * @throws Exceptions\GetMessagesFailedException
846 846
      * @throws Exceptions\RuntimeException
847 847
      */
848
-    protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){
848
+    protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder) {
849 849
         $primary_folder->query()->messageId($message_id)
850 850
         ->setFetchBody($this->getFetchBodyOption())
851 851
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -938,14 +938,14 @@  discard block
 block discarded – undo
938 938
      * @throws MessageFlagException
939 939
      * @throws MessageHeaderFetchingException
940 940
      */
941
-    protected function fetchNewMail($folder, $next_uid, $event, $expunge){
942
-        if($expunge) $this->client->expunge();
941
+    protected function fetchNewMail($folder, $next_uid, $event, $expunge) {
942
+        if ($expunge) $this->client->expunge();
943 943
 
944 944
         $this->client->openFolder($folder->path);
945 945
 
946 946
         if ($this->sequence === IMAP::ST_UID) {
947 947
             $sequence_id = $next_uid;
948
-        }else{
948
+        }else {
949 949
             $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
950 950
         }
951 951
 
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
      */
969 969
     public function delete($expunge = true) {
970 970
         $status = $this->setFlag("Deleted");
971
-        if($expunge) $this->client->expunge();
971
+        if ($expunge) $this->client->expunge();
972 972
 
973 973
         $event = $this->getEvent("message", "deleted");
974 974
         $event::dispatch($this);
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
      */
989 989
     public function restore($expunge = true) {
990 990
         $status = $this->unsetFlag("Deleted");
991
-        if($expunge) $this->client->expunge();
991
+        if ($expunge) $this->client->expunge();
992 992
 
993 993
         $event = $this->getEvent("message", "restored");
994 994
         $event::dispatch($this);
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
      *
1094 1094
      * @return AttachmentCollection
1095 1095
      */
1096
-    public function attachments(){
1096
+    public function attachments() {
1097 1097
         return $this->getAttachments();
1098 1098
     }
1099 1099
 
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
      *
1192 1192
      * @return FlagCollection
1193 1193
      */
1194
-    public function flags(){
1194
+    public function flags() {
1195 1195
         return $this->getFlags();
1196 1196
     }
1197 1197
 
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
      *
1201 1201
      * @return Structure|null
1202 1202
      */
1203
-    public function getStructure(){
1203
+    public function getStructure() {
1204 1204
         return $this->structure;
1205 1205
     }
1206 1206
 
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
      *
1227 1227
      * @return array
1228 1228
      */
1229
-    public function getAttributes(){
1229
+    public function getAttributes() {
1230 1230
         return array_merge($this->attributes, $this->header->getAttributes());
1231 1231
     }
1232 1232
 
@@ -1236,8 +1236,8 @@  discard block
 block discarded – undo
1236 1236
      *
1237 1237
      * @return $this
1238 1238
      */
1239
-    public function setMask($mask){
1240
-        if(class_exists($mask)){
1239
+    public function setMask($mask) {
1240
+        if (class_exists($mask)) {
1241 1241
             $this->mask = $mask;
1242 1242
         }
1243 1243
 
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
      *
1250 1250
      * @return string
1251 1251
      */
1252
-    public function getMask(){
1252
+    public function getMask() {
1253 1253
         return $this->mask;
1254 1254
     }
1255 1255
 
@@ -1260,9 +1260,9 @@  discard block
 block discarded – undo
1260 1260
      * @return mixed
1261 1261
      * @throws MaskNotFoundException
1262 1262
      */
1263
-    public function mask($mask = null){
1263
+    public function mask($mask = null) {
1264 1264
         $mask = $mask !== null ? $mask : $this->mask;
1265
-        if(class_exists($mask)){
1265
+        if (class_exists($mask)) {
1266 1266
             return new $mask($this);
1267 1267
         }
1268 1268
 
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
      *
1276 1276
      * @return $this
1277 1277
      */
1278
-    public function setFolderPath($folder_path){
1278
+    public function setFolderPath($folder_path) {
1279 1279
         $this->folder_path = $folder_path;
1280 1280
 
1281 1281
         return $this;
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
      *
1288 1288
      * @return $this
1289 1289
      */
1290
-    public function setConfig($config){
1290
+    public function setConfig($config) {
1291 1291
         $this->config = $config;
1292 1292
 
1293 1293
         return $this;
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
      *
1300 1300
      * @return $this
1301 1301
      */
1302
-    public function setAvailableFlags($available_flags){
1302
+    public function setAvailableFlags($available_flags) {
1303 1303
         $this->available_flags = $available_flags;
1304 1304
 
1305 1305
         return $this;
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
      *
1312 1312
      * @return $this
1313 1313
      */
1314
-    public function setAttachments($attachments){
1314
+    public function setAttachments($attachments) {
1315 1315
         $this->attachments = $attachments;
1316 1316
 
1317 1317
         return $this;
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
      *
1324 1324
      * @return $this
1325 1325
      */
1326
-    public function setFlags($flags){
1326
+    public function setFlags($flags) {
1327 1327
         $this->flags = $flags;
1328 1328
 
1329 1329
         return $this;
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
      * @throws Exceptions\RuntimeException
1338 1338
      * @throws Exceptions\ConnectionFailedException
1339 1339
      */
1340
-    public function setClient($client){
1340
+    public function setClient($client) {
1341 1341
         $this->client = $client;
1342 1342
         $this->client->openFolder($this->folder_path);
1343 1343
 
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
      * @throws Exceptions\RuntimeException
1353 1353
      * @return $this
1354 1354
      */
1355
-    public function setUid($uid){
1355
+    public function setUid($uid) {
1356 1356
         $this->uid = $uid;
1357 1357
         $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid);
1358 1358
         $this->msglist = null;
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
      * @throws Exceptions\RuntimeException
1370 1370
      * @return $this
1371 1371
      */
1372
-    public function setMsgn($msgn, $msglist = null){
1372
+    public function setMsgn($msgn, $msglist = null) {
1373 1373
         $this->msgn = $msgn;
1374 1374
         $this->msglist = $msglist;
1375 1375
         $this->uid = $this->client->getConnection()->getUid($this->msgn);
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
      *
1383 1383
      * @return int
1384 1384
      */
1385
-    public function getSequence(){
1385
+    public function getSequence() {
1386 1386
         return $this->sequence;
1387 1387
     }
1388 1388
 
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
      *
1392 1392
      * @return int
1393 1393
      */
1394
-    public function getSequenceId(){
1394
+    public function getSequenceId() {
1395 1395
         return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn;
1396 1396
     }
1397 1397
 
@@ -1403,11 +1403,11 @@  discard block
 block discarded – undo
1403 1403
      * @throws Exceptions\ConnectionFailedException
1404 1404
      * @throws Exceptions\RuntimeException
1405 1405
      */
1406
-    public function setSequenceId($uid, $msglist = null){
1406
+    public function setSequenceId($uid, $msglist = null) {
1407 1407
         if ($this->getSequence() === IMAP::ST_UID) {
1408 1408
             $this->setUid($uid);
1409 1409
             $this->setMsglist($msglist);
1410
-        }else{
1410
+        }else {
1411 1411
             $this->setMsgn($uid, $msglist);
1412 1412
         }
1413 1413
     }
Please login to merge, or discard this patch.
src/Support/Masks/MessageMask.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @return null
32 32
      */
33
-    public function getHtmlBody(){
33
+    public function getHtmlBody() {
34 34
         $bodies = $this->parent->getBodies();
35 35
         if (!isset($bodies['html'])) {
36 36
             return null;
37 37
         }
38 38
 
39
-        if(is_object($bodies['html']) && property_exists($bodies['html'], 'content')) {
39
+        if (is_object($bodies['html']) && property_exists($bodies['html'], 'content')) {
40 40
             return $bodies['html']->content;
41 41
         }
42 42
         return $bodies['html'];
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function getCustomHTMLBody($callback = false) {
52 52
         $body = $this->getHtmlBody();
53
-        if($body === null) return null;
53
+        if ($body === null) return null;
54 54
 
55 55
         if ($callback !== false) {
56 56
             $aAttachment = $this->parent->getAttachments();
57 57
             $aAttachment->each(function($oAttachment) use(&$body, $callback) {
58 58
                 /** @var Attachment $oAttachment */
59
-                if(is_callable($callback)) {
59
+                if (is_callable($callback)) {
60 60
                     $body = $callback($body, $oAttachment);
61
-                }elseif(is_string($callback)) {
61
+                }elseif (is_string($callback)) {
62 62
                     call_user_func($callback, [$body, $oAttachment]);
63 63
                 }
64 64
             });
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @return string|null
75 75
      */
76 76
     public function getHTMLBodyWithEmbeddedBase64Images() {
77
-        return $this->getCustomHTMLBody(function($body, $oAttachment){
77
+        return $this->getCustomHTMLBody(function($body, $oAttachment) {
78 78
             /** @var Attachment $oAttachment */
79 79
             if ($oAttachment->id) {
80 80
                 $body = str_replace('cid:'.$oAttachment->id, 'data:'.$oAttachment->getContentType().';base64, '.base64_encode($oAttachment->getContent()), $body);
Please login to merge, or discard this patch.