Passed
Push — master ( 96eb05...88c81a )
by Malte
04:07
created
src/IMAP/Message.php 2 patches
Spacing   +35 added lines, -35 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 = null, $fetch_attachment = null, $fetch_flags = null) {
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
 
@@ -377,16 +377,16 @@  discard block
 block discarded – undo
377 377
         }
378 378
 
379 379
         if (property_exists($header, 'subject')) {
380
-            if($this->config['decoder']['message']['subject'] === 'utf-8') {
380
+            if ($this->config['decoder']['message']['subject'] === 'utf-8') {
381 381
                 $this->subject = \imap_utf8($header->subject);
382
-            }elseif($this->config['decoder']['message']['subject'] === 'iconv') {
382
+            }elseif ($this->config['decoder']['message']['subject'] === 'iconv') {
383 383
                 $this->subject = iconv_mime_decode($header->subject);
384
-            }else{
384
+            } else {
385 385
                 $this->subject = mb_decode_mimeheader($header->subject);
386 386
             }
387 387
         }
388 388
 
389
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){
389
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) {
390 390
             $this->extractHeaderAddressPart($header, $part);
391 391
         }
392 392
 
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
      * @return int|null
417 417
      */
418 418
     private function extractPriority($header) {
419
-        if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){
419
+        if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) {
420 420
             $priority = isset($priority[1]) ? (int) $priority[1] : 0;
421
-            switch($priority){
421
+            switch ($priority) {
422 422
                 case IMAP::MESSAGE_PRIORITY_HIGHEST;
423 423
                     $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
424 424
                     break;
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
         if (property_exists($header, 'date')) {
470 470
             $date = $header->date;
471 471
 
472
-            if(preg_match('/\+0580/', $date)) {
472
+            if (preg_match('/\+0580/', $date)) {
473 473
                 $date = str_replace('+0580', '+0530', $date);
474 474
             }
475 475
 
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
                         $date = trim(array_pop($array));
493 493
                         break;
494 494
                 }
495
-                try{
495
+                try {
496 496
                     $parsed_date = Carbon::parse($date);
497 497
                 } catch (\Exception $_e) {
498 498
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e);
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
         $this->client->openFolder($this->folder_path);
516 516
         $flags = \imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID);
517 517
         if (is_array($flags) && isset($flags[0])) {
518
-            foreach($this->available_flags as $flag) {
518
+            foreach ($this->available_flags as $flag) {
519 519
                 $this->parseFlag($flags, $flag);
520 520
             }
521 521
         }
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
             } else {
588 588
                 $personalParts = \imap_mime_header_decode($address->personal);
589 589
 
590
-                if(is_array($personalParts)) {
590
+                if (is_array($personalParts)) {
591 591
                     $address->personal = '';
592 592
                     foreach ($personalParts as $p) {
593 593
                         $encoding = (property_exists($p, 'charset')) ? $p->charset : $this->getEncoding($p->text);
@@ -615,12 +615,12 @@  discard block
 block discarded – undo
615 615
         $this->client->openFolder($this->folder_path);
616 616
         $this->structure = \imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID);
617 617
 
618
-        if(property_exists($this->structure, 'parts')){
618
+        if (property_exists($this->structure, 'parts')) {
619 619
             $parts = $this->structure->parts;
620 620
 
621
-            foreach ($parts as $part)  {
622
-                foreach ($part->parameters as $parameter)  {
623
-                    if($parameter->attribute == "charset")  {
621
+            foreach ($parts as $part) {
622
+                foreach ($part->parameters as $parameter) {
623
+                    if ($parameter->attribute == "charset") {
624 624
                         $encoding = $parameter->value;
625 625
 
626 626
                         $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding);
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
                     return EncodingAliases::get($parameter->value);
900 900
                 }
901 901
             }
902
-        }elseif (is_string($structure) === true){
902
+        }elseif (is_string($structure) === true) {
903 903
             return mb_detect_encoding($structure);
904 904
         }
905 905
 
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
         return null;
950 950
     }
951 951
 
952
-    public function getFolder(){
952
+    public function getFolder() {
953 953
         return $this->client->getFolder($this->folder_path);
954 954
     }
955 955
 
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
      */
966 966
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
967 967
 
968
-        if($create_folder) $this->client->createFolder($mailbox, true);
968
+        if ($create_folder) $this->client->createFolder($mailbox, true);
969 969
 
970 970
         $target_folder = $this->client->getFolder($mailbox);
971 971
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
         $this->client->openFolder($this->folder_path);
974 974
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
975 975
 
976
-        if($status === true){
977
-            if($expunge) $this->client->expunge();
976
+        if ($status === true) {
977
+            if ($expunge) $this->client->expunge();
978 978
             $this->client->openFolder($target_folder->path);
979 979
 
980 980
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
         $this->client->openFolder($this->folder_path);
997 997
 
998 998
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
999
-        if($expunge) $this->client->expunge();
999
+        if ($expunge) $this->client->expunge();
1000 1000
         MessageDeletedEvent::dispatch($this);
1001 1001
 
1002 1002
         return $status;
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
         $this->client->openFolder($this->folder_path);
1014 1014
 
1015 1015
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1016
-        if($expunge) $this->client->expunge();
1016
+        if ($expunge) $this->client->expunge();
1017 1017
         MessageRestoredEvent::dispatch($this);
1018 1018
 
1019 1019
         return $status;
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
      * @return string
1091 1091
      * @throws Exceptions\ConnectionFailedException
1092 1092
      */
1093
-    public function getToken(){
1093
+    public function getToken() {
1094 1094
         return base64_encode(implode('-', [$this->message_id, $this->subject, strlen($this->getRawBody())]));
1095 1095
     }
1096 1096
 
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
     /**
1154 1154
      * @return object|null
1155 1155
      */
1156
-    public function getStructure(){
1156
+    public function getStructure() {
1157 1157
         return $this->structure;
1158 1158
     }
1159 1159
 
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
     /**
1180 1180
      * @return array
1181 1181
      */
1182
-    public function getAttributes(){
1182
+    public function getAttributes() {
1183 1183
         return $this->attributes;
1184 1184
     }
1185 1185
 
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
      * @param $mask
1188 1188
      * @return $this
1189 1189
      */
1190
-    public function setMask($mask){
1191
-        if(class_exists($mask)){
1190
+    public function setMask($mask) {
1191
+        if (class_exists($mask)) {
1192 1192
             $this->mask = $mask;
1193 1193
         }
1194 1194
 
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
     /**
1199 1199
      * @return string
1200 1200
      */
1201
-    public function getMask(){
1201
+    public function getMask() {
1202 1202
         return $this->mask;
1203 1203
     }
1204 1204
 
@@ -1209,9 +1209,9 @@  discard block
 block discarded – undo
1209 1209
      * @return mixed
1210 1210
      * @throws MaskNotFoundException
1211 1211
      */
1212
-    public function mask($mask = null){
1212
+    public function mask($mask = null) {
1213 1213
         $mask = $mask !== null ? $mask : $this->mask;
1214
-        if(class_exists($mask)){
1214
+        if (class_exists($mask)) {
1215 1215
             return new $mask($this);
1216 1216
         }
1217 1217
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 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))) {
@@ -379,9 +379,9 @@  discard block
 block discarded – undo
379 379
         if (property_exists($header, 'subject')) {
380 380
             if($this->config['decoder']['message']['subject'] === 'utf-8') {
381 381
                 $this->subject = \imap_utf8($header->subject);
382
-            }elseif($this->config['decoder']['message']['subject'] === 'iconv') {
382
+            } elseif($this->config['decoder']['message']['subject'] === 'iconv') {
383 383
                 $this->subject = iconv_mime_decode($header->subject);
384
-            }else{
384
+            } else{
385 385
                 $this->subject = mb_decode_mimeheader($header->subject);
386 386
             }
387 387
         }
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
                     return EncodingAliases::get($parameter->value);
900 900
                 }
901 901
             }
902
-        }elseif (is_string($structure) === true){
902
+        } elseif (is_string($structure) === true){
903 903
             return mb_detect_encoding($structure);
904 904
         }
905 905
 
@@ -965,7 +965,9 @@  discard block
 block discarded – undo
965 965
      */
966 966
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
967 967
 
968
-        if($create_folder) $this->client->createFolder($mailbox, true);
968
+        if($create_folder) {
969
+            $this->client->createFolder($mailbox, true);
970
+        }
969 971
 
970 972
         $target_folder = $this->client->getFolder($mailbox);
971 973
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -974,7 +976,9 @@  discard block
 block discarded – undo
974 976
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
975 977
 
976 978
         if($status === true){
977
-            if($expunge) $this->client->expunge();
979
+            if($expunge) {
980
+                $this->client->expunge();
981
+            }
978 982
             $this->client->openFolder($target_folder->path);
979 983
 
980 984
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -996,7 +1000,9 @@  discard block
 block discarded – undo
996 1000
         $this->client->openFolder($this->folder_path);
997 1001
 
998 1002
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
999
-        if($expunge) $this->client->expunge();
1003
+        if($expunge) {
1004
+            $this->client->expunge();
1005
+        }
1000 1006
         MessageDeletedEvent::dispatch($this);
1001 1007
 
1002 1008
         return $status;
@@ -1013,7 +1019,9 @@  discard block
 block discarded – undo
1013 1019
         $this->client->openFolder($this->folder_path);
1014 1020
 
1015 1021
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1016
-        if($expunge) $this->client->expunge();
1022
+        if($expunge) {
1023
+            $this->client->expunge();
1024
+        }
1017 1025
         MessageRestoredEvent::dispatch($this);
1018 1026
 
1019 1027
         return $status;
Please login to merge, or discard this patch.