Passed
Push — master ( 91f2bd...b0bac1 )
by Malte
04:28
created
src/IMAP/Message.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = null, $fetch_attachment = null, $fetch_flags = null) {
208 208
 
209 209
         $default_mask = $client->getDefaultMessageMask();
210
-        if($default_mask != null) {
210
+        if ($default_mask != null) {
211 211
             $this->mask = $default_mask;
212 212
         }
213 213
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         $this->msglist = $msglist;
227 227
         $this->client = $client;
228 228
 
229
-        $this->uid =  ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
229
+        $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
230 230
         $this->msgn = ($this->fetch_options == IMAP::FT_UID) ? \imap_msgno($this->client->getConnection(), $uid) : $uid;
231 231
 
232 232
         $this->parseHeader();
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
      * @throws MethodNotFoundException
250 250
      */
251 251
     public function __call($method, $arguments) {
252
-        if(strtolower(substr($method, 0, 3)) === 'get') {
252
+        if (strtolower(substr($method, 0, 3)) === 'get') {
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
                 return $this->attributes[$name];
257 257
             }
258 258
 
259 259
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
260 260
             $name = Str::snake(substr($method, 3));
261 261
 
262
-            if(in_array($name, array_keys($this->attributes))) {
262
+            if (in_array($name, array_keys($this->attributes))) {
263 263
                 $this->attributes[$name] = array_pop($arguments);
264 264
 
265 265
                 return $this->attributes[$name];
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      * @return mixed|null
289 289
      */
290 290
     public function __get($name) {
291
-        if(isset($this->attributes[$name])) {
291
+        if (isset($this->attributes[$name])) {
292 292
             return $this->attributes[$name];
293 293
         }
294 294
 
@@ -384,16 +384,16 @@  discard block
 block discarded – undo
384 384
         }
385 385
 
386 386
         if (property_exists($header, 'subject')) {
387
-            if($this->config['decoder']['message']['subject'] === 'utf-8') {
387
+            if ($this->config['decoder']['message']['subject'] === 'utf-8') {
388 388
                 $this->subject = \imap_utf8($header->subject);
389
-            }elseif($this->config['decoder']['message']['subject'] === 'iconv') {
389
+            }elseif ($this->config['decoder']['message']['subject'] === 'iconv') {
390 390
                 $this->subject = iconv_mime_decode($header->subject);
391
-            }else{
391
+            } else {
392 392
                 $this->subject = mb_decode_mimeheader($header->subject);
393 393
             }
394 394
         }
395 395
 
396
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){
396
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) {
397 397
             $this->extractHeaderAddressPart($header, $part);
398 398
         }
399 399
 
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
      * @return int|null
424 424
      */
425 425
     private function extractPriority($header) {
426
-        if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){
426
+        if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) {
427 427
             $priority = isset($priority[1]) ? (int) $priority[1] : 0;
428
-            switch($priority){
428
+            switch ($priority) {
429 429
                 case IMAP::MESSAGE_PRIORITY_HIGHEST;
430 430
                     $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
431 431
                     break;
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
         if (property_exists($header, 'date')) {
477 477
             $date = $header->date;
478 478
 
479
-            if(preg_match('/\+0580/', $date)) {
479
+            if (preg_match('/\+0580/', $date)) {
480 480
                 $date = str_replace('+0580', '+0530', $date);
481 481
             }
482 482
 
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
                         $date = trim(array_pop($array));
500 500
                         break;
501 501
                 }
502
-                try{
502
+                try {
503 503
                     $parsed_date = Carbon::parse($date);
504 504
                 } catch (\Exception $_e) {
505 505
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e);
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         $this->client->openFolder($this->folder_path);
523 523
         $flags = \imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID);
524 524
         if (is_array($flags) && isset($flags[0])) {
525
-            foreach($this->available_flags as $flag) {
525
+            foreach ($this->available_flags as $flag) {
526 526
                 $this->parseFlag($flags, $flag);
527 527
             }
528 528
         }
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
             } else {
595 595
                 $personalParts = \imap_mime_header_decode($address->personal);
596 596
 
597
-                if(is_array($personalParts)) {
597
+                if (is_array($personalParts)) {
598 598
                     $address->personal = '';
599 599
                     foreach ($personalParts as $p) {
600 600
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -621,12 +621,12 @@  discard block
 block discarded – undo
621 621
         $this->client->openFolder($this->folder_path);
622 622
         $this->structure = \imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID);
623 623
 
624
-        if(property_exists($this->structure, 'parts')){
624
+        if (property_exists($this->structure, 'parts')) {
625 625
             $parts = $this->structure->parts;
626 626
 
627
-            foreach ($parts as $part)  {
628
-                foreach ($part->parameters as $parameter)  {
629
-                    if($parameter->attribute == "charset")  {
627
+            foreach ($parts as $part) {
628
+                foreach ($part->parameters as $parameter) {
629
+                    if ($parameter->attribute == "charset") {
630 630
                         $encoding = $parameter->value;
631 631
 
632 632
                         $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding);
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
             }
908 908
         }elseif (property_exists($structure, 'charset')) {
909 909
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
910
-        }elseif (is_string($structure) === true){
910
+        }elseif (is_string($structure) === true) {
911 911
             return mb_detect_encoding($structure);
912 912
         }
913 913
 
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
         return null;
958 958
     }
959 959
 
960
-    public function getFolder(){
960
+    public function getFolder() {
961 961
         return $this->client->getFolder($this->folder_path);
962 962
     }
963 963
 
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
      */
974 974
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
975 975
 
976
-        if($create_folder) $this->client->createFolder($mailbox, true);
976
+        if ($create_folder) $this->client->createFolder($mailbox, true);
977 977
 
978 978
         $target_folder = $this->client->getFolder($mailbox);
979 979
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
         $this->client->openFolder($this->folder_path);
982 982
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
983 983
 
984
-        if($status === true){
985
-            if($expunge) $this->client->expunge();
984
+        if ($status === true) {
985
+            if ($expunge) $this->client->expunge();
986 986
             $this->client->openFolder($target_folder->path);
987 987
 
988 988
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
         $this->client->openFolder($this->folder_path);
1005 1005
 
1006 1006
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1007
-        if($expunge) $this->client->expunge();
1007
+        if ($expunge) $this->client->expunge();
1008 1008
         MessageDeletedEvent::dispatch($this);
1009 1009
 
1010 1010
         return $status;
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
         $this->client->openFolder($this->folder_path);
1022 1022
 
1023 1023
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1024
-        if($expunge) $this->client->expunge();
1024
+        if ($expunge) $this->client->expunge();
1025 1025
         MessageRestoredEvent::dispatch($this);
1026 1026
 
1027 1027
         return $status;
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
      * @return string
1099 1099
      * @throws Exceptions\ConnectionFailedException
1100 1100
      */
1101
-    public function getToken(){
1101
+    public function getToken() {
1102 1102
         return base64_encode(implode('-', [$this->message_id, $this->subject, strlen($this->getRawBody())]));
1103 1103
     }
1104 1104
 
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
     /**
1162 1162
      * @return object|null
1163 1163
      */
1164
-    public function getStructure(){
1164
+    public function getStructure() {
1165 1165
         return $this->structure;
1166 1166
     }
1167 1167
 
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
     /**
1188 1188
      * @return array
1189 1189
      */
1190
-    public function getAttributes(){
1190
+    public function getAttributes() {
1191 1191
         return $this->attributes;
1192 1192
     }
1193 1193
 
@@ -1195,8 +1195,8 @@  discard block
 block discarded – undo
1195 1195
      * @param $mask
1196 1196
      * @return $this
1197 1197
      */
1198
-    public function setMask($mask){
1199
-        if(class_exists($mask)){
1198
+    public function setMask($mask) {
1199
+        if (class_exists($mask)) {
1200 1200
             $this->mask = $mask;
1201 1201
         }
1202 1202
 
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
     /**
1207 1207
      * @return string
1208 1208
      */
1209
-    public function getMask(){
1209
+    public function getMask() {
1210 1210
         return $this->mask;
1211 1211
     }
1212 1212
 
@@ -1217,9 +1217,9 @@  discard block
 block discarded – undo
1217 1217
      * @return mixed
1218 1218
      * @throws MaskNotFoundException
1219 1219
      */
1220
-    public function mask($mask = null){
1220
+    public function mask($mask = null) {
1221 1221
         $mask = $mask !== null ? $mask : $this->mask;
1222
-        if(class_exists($mask)){
1222
+        if (class_exists($mask)) {
1223 1223
             return new $mask($this);
1224 1224
         }
1225 1225
 
Please login to merge, or discard this patch.
Braces   +17 added lines, -9 removed lines patch added patch discarded remove patch
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                 return $this->attributes[$name];
257 257
             }
258 258
 
259
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
259
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
260 260
             $name = Str::snake(substr($method, 3));
261 261
 
262 262
             if(in_array($name, array_keys($this->attributes))) {
@@ -386,9 +386,9 @@  discard block
 block discarded – undo
386 386
         if (property_exists($header, 'subject')) {
387 387
             if($this->config['decoder']['message']['subject'] === 'utf-8') {
388 388
                 $this->subject = \imap_utf8($header->subject);
389
-            }elseif($this->config['decoder']['message']['subject'] === 'iconv') {
389
+            } elseif($this->config['decoder']['message']['subject'] === 'iconv') {
390 390
                 $this->subject = iconv_mime_decode($header->subject);
391
-            }else{
391
+            } else{
392 392
                 $this->subject = mb_decode_mimeheader($header->subject);
393 393
             }
394 394
         }
@@ -905,9 +905,9 @@  discard block
 block discarded – undo
905 905
                     return EncodingAliases::get($parameter->value, $this->fallback_encoding);
906 906
                 }
907 907
             }
908
-        }elseif (property_exists($structure, 'charset')) {
908
+        } elseif (property_exists($structure, 'charset')) {
909 909
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
910
-        }elseif (is_string($structure) === true){
910
+        } elseif (is_string($structure) === true){
911 911
             return mb_detect_encoding($structure);
912 912
         }
913 913
 
@@ -973,7 +973,9 @@  discard block
 block discarded – undo
973 973
      */
974 974
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
975 975
 
976
-        if($create_folder) $this->client->createFolder($mailbox, true);
976
+        if($create_folder) {
977
+            $this->client->createFolder($mailbox, true);
978
+        }
977 979
 
978 980
         $target_folder = $this->client->getFolder($mailbox);
979 981
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -982,7 +984,9 @@  discard block
 block discarded – undo
982 984
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
983 985
 
984 986
         if($status === true){
985
-            if($expunge) $this->client->expunge();
987
+            if($expunge) {
988
+                $this->client->expunge();
989
+            }
986 990
             $this->client->openFolder($target_folder->path);
987 991
 
988 992
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1004,7 +1008,9 @@  discard block
 block discarded – undo
1004 1008
         $this->client->openFolder($this->folder_path);
1005 1009
 
1006 1010
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1007
-        if($expunge) $this->client->expunge();
1011
+        if($expunge) {
1012
+            $this->client->expunge();
1013
+        }
1008 1014
         MessageDeletedEvent::dispatch($this);
1009 1015
 
1010 1016
         return $status;
@@ -1021,7 +1027,9 @@  discard block
 block discarded – undo
1021 1027
         $this->client->openFolder($this->folder_path);
1022 1028
 
1023 1029
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1024
-        if($expunge) $this->client->expunge();
1030
+        if($expunge) {
1031
+            $this->client->expunge();
1032
+        }
1025 1033
         MessageRestoredEvent::dispatch($this);
1026 1034
 
1027 1035
         return $status;
Please login to merge, or discard this patch.