Passed
Push — master ( b7e336...b99c9f )
by Malte
04:40
created
src/IMAP/Message.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = false) {
201 201
 
202 202
         $default_mask = $client->getDefaultMessageMask();
203
-        if($default_mask != null) {
203
+        if ($default_mask != null) {
204 204
             $this->mask = $default_mask;
205 205
         }
206 206
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $this->msglist = $msglist;
220 220
         $this->client = $client;
221 221
 
222
-        $this->uid =  ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
222
+        $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
223 223
         $this->msgn = ($this->fetch_options == IMAP::FT_UID) ? \imap_msgno($this->client->getConnection(), $uid) : $uid;
224 224
 
225 225
         $this->parseHeader();
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
      * @throws MethodNotFoundException
243 243
      */
244 244
     public function __call($method, $arguments) {
245
-        if(strtolower(substr($method, 0, 3)) === 'get') {
245
+        if (strtolower(substr($method, 0, 3)) === 'get') {
246 246
             $name = Str::snake(substr($method, 3));
247 247
 
248
-            if(in_array($name, array_keys($this->attributes))) {
248
+            if (in_array($name, array_keys($this->attributes))) {
249 249
                 return $this->attributes[$name];
250 250
             }
251 251
 
252 252
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
253 253
             $name = Str::snake(substr($method, 3));
254 254
 
255
-            if(in_array($name, array_keys($this->attributes))) {
255
+            if (in_array($name, array_keys($this->attributes))) {
256 256
                 $this->attributes[$name] = array_pop($arguments);
257 257
 
258 258
                 return $this->attributes[$name];
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      * @return mixed|null
282 282
      */
283 283
     public function __get($name) {
284
-        if(isset($this->attributes[$name])) {
284
+        if (isset($this->attributes[$name])) {
285 285
             return $this->attributes[$name];
286 286
         }
287 287
 
@@ -367,11 +367,11 @@  discard block
 block discarded – undo
367 367
         if ($replaceImages !== false) {
368 368
             $this->attachments->each(function($oAttachment) use(&$body, $replaceImages) {
369 369
                 /** @var Attachment $oAttachment */
370
-                if(is_callable($replaceImages)) {
370
+                if (is_callable($replaceImages)) {
371 371
                     $body = $replaceImages($body, $oAttachment);
372
-                }elseif(is_string($replaceImages)) {
372
+                }elseif (is_string($replaceImages)) {
373 373
                     call_user_func($replaceImages, [$body, $oAttachment]);
374
-                }else{
374
+                } else {
375 375
                     if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
376 376
                         $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
377 377
                     }
@@ -400,16 +400,16 @@  discard block
 block discarded – undo
400 400
         }
401 401
 
402 402
         if (property_exists($header, 'subject')) {
403
-            if($this->config['decoder']['message']['subject'] === 'utf-8') {
403
+            if ($this->config['decoder']['message']['subject'] === 'utf-8') {
404 404
                 $this->subject = \imap_utf8($header->subject);
405
-            }elseif($this->config['decoder']['message']['subject'] === 'iconv') {
405
+            }elseif ($this->config['decoder']['message']['subject'] === 'iconv') {
406 406
                 $this->subject = iconv_mime_decode($header->subject);
407
-            }else{
407
+            } else {
408 408
                 $this->subject = mb_decode_mimeheader($header->subject);
409 409
             }
410 410
         }
411 411
 
412
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){
412
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) {
413 413
             $this->extractHeaderAddressPart($header, $part);
414 414
         }
415 415
 
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
      * @return int|null
440 440
      */
441 441
     private function extractPriority($header) {
442
-        if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){
442
+        if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) {
443 443
             $priority = isset($priority[1]) ? (int) $priority[1] : 0;
444
-            switch($priority){
444
+            switch ($priority) {
445 445
                 case IMAP::MESSAGE_PRIORITY_HIGHEST;
446 446
                     $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
447 447
                     break;
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
         if (property_exists($header, 'date')) {
493 493
             $date = $header->date;
494 494
 
495
-            if(preg_match('/\+0580/', $date)) {
495
+            if (preg_match('/\+0580/', $date)) {
496 496
                 $date = str_replace('+0580', '+0530', $date);
497 497
             }
498 498
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
                         $date = trim(array_pop($array));
516 516
                         break;
517 517
                 }
518
-                try{
518
+                try {
519 519
                     $parsed_date = Carbon::parse($date);
520 520
                 } catch (\Exception $_e) {
521 521
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e);
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
         $this->client->openFolder($this->folder_path);
539 539
         $flags = \imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID);
540 540
         if (is_array($flags) && isset($flags[0])) {
541
-            foreach($this->available_flags as $flag) {
541
+            foreach ($this->available_flags as $flag) {
542 542
                 $this->parseFlag($flags, $flag);
543 543
             }
544 544
         }
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
             } else {
611 611
                 $personalParts = \imap_mime_header_decode($address->personal);
612 612
 
613
-                if(is_array($personalParts)) {
613
+                if (is_array($personalParts)) {
614 614
                     $address->personal = '';
615 615
                     foreach ($personalParts as $p) {
616 616
                         $encoding = (property_exists($p, 'charset')) ? $p->charset : $this->getEncoding($p->text);
@@ -638,12 +638,12 @@  discard block
 block discarded – undo
638 638
         $this->client->openFolder($this->folder_path);
639 639
         $this->structure = \imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID);
640 640
 
641
-        if(property_exists($this->structure, 'parts')){
641
+        if (property_exists($this->structure, 'parts')) {
642 642
             $parts = $this->structure->parts;
643 643
 
644
-            foreach ($parts as $part)  {
645
-                foreach ($part->parameters as $parameter)  {
646
-                    if($parameter->attribute == "charset")  {
644
+            foreach ($parts as $part) {
645
+                foreach ($part->parameters as $parameter) {
646
+                    if ($parameter->attribute == "charset") {
647 647
                         $encoding = $parameter->value;
648 648
 
649 649
                         $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding);
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
                     return EncodingAliases::get($parameter->value);
923 923
                 }
924 924
             }
925
-        }elseif (is_string($structure) === true){
925
+        }elseif (is_string($structure) === true) {
926 926
             return mb_detect_encoding($structure);
927 927
         }
928 928
 
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
         return null;
973 973
     }
974 974
 
975
-    public function getFolder(){
975
+    public function getFolder() {
976 976
         return $this->client->getFolder($this->folder_path);
977 977
     }
978 978
 
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
      */
989 989
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
990 990
 
991
-        if($create_folder) $this->client->createFolder($mailbox, true);
991
+        if ($create_folder) $this->client->createFolder($mailbox, true);
992 992
 
993 993
         $target_folder = $this->client->getFolder($mailbox);
994 994
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
         $this->client->openFolder($this->folder_path);
997 997
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
998 998
 
999
-        if($status === true){
1000
-            if($expunge) $this->client->expunge();
999
+        if ($status === true) {
1000
+            if ($expunge) $this->client->expunge();
1001 1001
             $this->client->openFolder($target_folder->path);
1002 1002
 
1003 1003
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
         $this->client->openFolder($this->folder_path);
1020 1020
 
1021 1021
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1022
-        if($expunge) $this->client->expunge();
1022
+        if ($expunge) $this->client->expunge();
1023 1023
         MessageDeletedEvent::dispatch($this);
1024 1024
 
1025 1025
         return $status;
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
         $this->client->openFolder($this->folder_path);
1037 1037
 
1038 1038
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1039
-        if($expunge) $this->client->expunge();
1039
+        if ($expunge) $this->client->expunge();
1040 1040
         MessageRestoredEvent::dispatch($this);
1041 1041
 
1042 1042
         return $status;
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
     /**
1168 1168
      * @return object|null
1169 1169
      */
1170
-    public function getStructure(){
1170
+    public function getStructure() {
1171 1171
         return $this->structure;
1172 1172
     }
1173 1173
 
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
     /**
1194 1194
      * @return array
1195 1195
      */
1196
-    public function getAttributes(){
1196
+    public function getAttributes() {
1197 1197
         return $this->attributes;
1198 1198
     }
1199 1199
 
@@ -1201,8 +1201,8 @@  discard block
 block discarded – undo
1201 1201
      * @param $mask
1202 1202
      * @return $this
1203 1203
      */
1204
-    public function setMask($mask){
1205
-        if(class_exists($mask)){
1204
+    public function setMask($mask) {
1205
+        if (class_exists($mask)) {
1206 1206
             $this->mask = $mask;
1207 1207
         }
1208 1208
 
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
     /**
1213 1213
      * @return string
1214 1214
      */
1215
-    public function getMask(){
1215
+    public function getMask() {
1216 1216
         return $this->mask;
1217 1217
     }
1218 1218
 
@@ -1223,9 +1223,9 @@  discard block
 block discarded – undo
1223 1223
      * @return mixed
1224 1224
      * @throws MaskNotFoundException
1225 1225
      */
1226
-    public function mask($mask = null){
1226
+    public function mask($mask = null) {
1227 1227
         $mask = $mask !== null ? $mask : $this->mask;
1228
-        if(class_exists($mask)){
1228
+        if (class_exists($mask)) {
1229 1229
             return new $mask($this);
1230 1230
         }
1231 1231
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -10 removed lines patch added patch discarded remove patch
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
                 return $this->attributes[$name];
250 250
             }
251 251
 
252
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
252
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
253 253
             $name = Str::snake(substr($method, 3));
254 254
 
255 255
             if(in_array($name, array_keys($this->attributes))) {
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
                 /** @var Attachment $oAttachment */
370 370
                 if(is_callable($replaceImages)) {
371 371
                     $body = $replaceImages($body, $oAttachment);
372
-                }elseif(is_string($replaceImages)) {
372
+                } elseif(is_string($replaceImages)) {
373 373
                     call_user_func($replaceImages, [$body, $oAttachment]);
374
-                }else{
374
+                } else{
375 375
                     if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
376 376
                         $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
377 377
                     }
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
         if (property_exists($header, 'subject')) {
403 403
             if($this->config['decoder']['message']['subject'] === 'utf-8') {
404 404
                 $this->subject = \imap_utf8($header->subject);
405
-            }elseif($this->config['decoder']['message']['subject'] === 'iconv') {
405
+            } elseif($this->config['decoder']['message']['subject'] === 'iconv') {
406 406
                 $this->subject = iconv_mime_decode($header->subject);
407
-            }else{
407
+            } else{
408 408
                 $this->subject = mb_decode_mimeheader($header->subject);
409 409
             }
410 410
         }
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
                     return EncodingAliases::get($parameter->value);
923 923
                 }
924 924
             }
925
-        }elseif (is_string($structure) === true){
925
+        } elseif (is_string($structure) === true){
926 926
             return mb_detect_encoding($structure);
927 927
         }
928 928
 
@@ -988,7 +988,9 @@  discard block
 block discarded – undo
988 988
      */
989 989
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
990 990
 
991
-        if($create_folder) $this->client->createFolder($mailbox, true);
991
+        if($create_folder) {
992
+            $this->client->createFolder($mailbox, true);
993
+        }
992 994
 
993 995
         $target_folder = $this->client->getFolder($mailbox);
994 996
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -997,7 +999,9 @@  discard block
 block discarded – undo
997 999
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
998 1000
 
999 1001
         if($status === true){
1000
-            if($expunge) $this->client->expunge();
1002
+            if($expunge) {
1003
+                $this->client->expunge();
1004
+            }
1001 1005
             $this->client->openFolder($target_folder->path);
1002 1006
 
1003 1007
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1019,7 +1023,9 @@  discard block
 block discarded – undo
1019 1023
         $this->client->openFolder($this->folder_path);
1020 1024
 
1021 1025
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1022
-        if($expunge) $this->client->expunge();
1026
+        if($expunge) {
1027
+            $this->client->expunge();
1028
+        }
1023 1029
         MessageDeletedEvent::dispatch($this);
1024 1030
 
1025 1031
         return $status;
@@ -1036,7 +1042,9 @@  discard block
 block discarded – undo
1036 1042
         $this->client->openFolder($this->folder_path);
1037 1043
 
1038 1044
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1039
-        if($expunge) $this->client->expunge();
1045
+        if($expunge) {
1046
+            $this->client->expunge();
1047
+        }
1040 1048
         MessageRestoredEvent::dispatch($this);
1041 1049
 
1042 1050
         return $status;
Please login to merge, or discard this patch.