Passed
Push — master ( 310f46...0fdd8f )
by Malte
05:34
created
src/IMAP/Message.php 2 patches
Spacing   +33 added lines, -33 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 =  $uid;
229
+        $this->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,19 +384,19 @@  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 389
                 if (Str::startsWith(mb_strtolower($this->subject), '=?utf-8?')) {
390 390
                     $this->subject = mb_decode_mimeheader($header->subject);
391 391
                 }
392
-            }elseif($this->config['decoder']['message']['subject'] === 'iconv') {
392
+            }elseif ($this->config['decoder']['message']['subject'] === 'iconv') {
393 393
                 $this->subject = iconv_mime_decode($header->subject);
394
-            }else{
394
+            } else {
395 395
                 $this->subject = mb_decode_mimeheader($header->subject);
396 396
             }
397 397
         }
398 398
 
399
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){
399
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) {
400 400
             $this->extractHeaderAddressPart($header, $part);
401 401
         }
402 402
 
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
      * @return int|null
427 427
      */
428 428
     private function extractPriority($header) {
429
-        if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){
429
+        if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) {
430 430
             $priority = isset($priority[1]) ? (int) $priority[1] : 0;
431
-            switch($priority){
431
+            switch ($priority) {
432 432
                 case IMAP::MESSAGE_PRIORITY_HIGHEST;
433 433
                     $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
434 434
                     break;
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
         if (property_exists($header, 'date')) {
480 480
             $date = $header->date;
481 481
 
482
-            if(preg_match('/\+0580/', $date)) {
482
+            if (preg_match('/\+0580/', $date)) {
483 483
                 $date = str_replace('+0580', '+0530', $date);
484 484
             }
485 485
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
                         $date = trim(array_pop($array));
503 503
                         break;
504 504
                 }
505
-                try{
505
+                try {
506 506
                     $parsed_date = Carbon::parse($date);
507 507
                 } catch (\Exception $_e) {
508 508
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1100, $e);
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
         $this->client->openFolder($this->folder_path);
526 526
         $flags = \imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID);
527 527
         if (is_array($flags) && isset($flags[0])) {
528
-            foreach($this->available_flags as $flag) {
528
+            foreach ($this->available_flags as $flag) {
529 529
                 $this->parseFlag($flags, $flag);
530 530
             }
531 531
         }
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
             } else {
598 598
                 $personalParts = \imap_mime_header_decode($address->personal);
599 599
 
600
-                if(is_array($personalParts)) {
600
+                if (is_array($personalParts)) {
601 601
                     $address->personal = '';
602 602
                     foreach ($personalParts as $p) {
603 603
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
      * @return object
676 676
      * @throws Exceptions\ConnectionFailedException
677 677
      */
678
-    private function createBody($type, $structure, $partNumber){
678
+    private function createBody($type, $structure, $partNumber) {
679 679
         return (object) [
680 680
             "type" => $type,
681 681
             "content" => $this->fetchPart($structure, $partNumber),
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
      * @return mixed|string
691 691
      * @throws Exceptions\ConnectionFailedException
692 692
      */
693
-    private function fetchPart($structure, $partNumber){
693
+    private function fetchPart($structure, $partNumber) {
694 694
         $encoding = $this->getEncoding($structure);
695 695
 
696 696
         if (!$partNumber) {
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
             }
905 905
         }elseif (property_exists($structure, 'charset')) {
906 906
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
907
-        }elseif (is_string($structure) === true){
907
+        }elseif (is_string($structure) === true) {
908 908
             return mb_detect_encoding($structure);
909 909
         }
910 910
 
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
         return null;
955 955
     }
956 956
 
957
-    public function getFolder(){
957
+    public function getFolder() {
958 958
         return $this->client->getFolder($this->folder_path);
959 959
     }
960 960
 
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
      */
971 971
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
972 972
 
973
-        if($create_folder) $this->client->createFolder($mailbox, true);
973
+        if ($create_folder) $this->client->createFolder($mailbox, true);
974 974
 
975 975
         $target_folder = $this->client->getFolder($mailbox);
976 976
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -978,8 +978,8 @@  discard block
 block discarded – undo
978 978
         $this->client->openFolder($this->folder_path);
979 979
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
980 980
 
981
-        if($status === true){
982
-            if($expunge) $this->client->expunge();
981
+        if ($status === true) {
982
+            if ($expunge) $this->client->expunge();
983 983
             $this->client->openFolder($target_folder->path);
984 984
 
985 985
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
         $this->client->openFolder($this->folder_path);
1002 1002
 
1003 1003
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1004
-        if($expunge) $this->client->expunge();
1004
+        if ($expunge) $this->client->expunge();
1005 1005
         MessageDeletedEvent::dispatch($this);
1006 1006
 
1007 1007
         return $status;
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
         $this->client->openFolder($this->folder_path);
1019 1019
 
1020 1020
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1021
-        if($expunge) $this->client->expunge();
1021
+        if ($expunge) $this->client->expunge();
1022 1022
         MessageRestoredEvent::dispatch($this);
1023 1023
 
1024 1024
         return $status;
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
      * @return string
1096 1096
      * @throws Exceptions\ConnectionFailedException
1097 1097
      */
1098
-    public function getToken(){
1098
+    public function getToken() {
1099 1099
         return base64_encode(implode('-', [$this->message_id, $this->subject, strlen($this->getRawBody())]));
1100 1100
     }
1101 1101
 
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
     /**
1159 1159
      * @return object|null
1160 1160
      */
1161
-    public function getStructure(){
1161
+    public function getStructure() {
1162 1162
         return $this->structure;
1163 1163
     }
1164 1164
 
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
     /**
1183 1183
      * @return array
1184 1184
      */
1185
-    public function getAttributes(){
1185
+    public function getAttributes() {
1186 1186
         return $this->attributes;
1187 1187
     }
1188 1188
 
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
      * @param $mask
1191 1191
      * @return $this
1192 1192
      */
1193
-    public function setMask($mask){
1194
-        if(class_exists($mask)){
1193
+    public function setMask($mask) {
1194
+        if (class_exists($mask)) {
1195 1195
             $this->mask = $mask;
1196 1196
         }
1197 1197
 
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
     /**
1202 1202
      * @return string
1203 1203
      */
1204
-    public function getMask(){
1204
+    public function getMask() {
1205 1205
         return $this->mask;
1206 1206
     }
1207 1207
 
@@ -1212,9 +1212,9 @@  discard block
 block discarded – undo
1212 1212
      * @return mixed
1213 1213
      * @throws MaskNotFoundException
1214 1214
      */
1215
-    public function mask($mask = null){
1215
+    public function mask($mask = null) {
1216 1216
         $mask = $mask !== null ? $mask : $this->mask;
1217
-        if(class_exists($mask)){
1217
+        if (class_exists($mask)) {
1218 1218
             return new $mask($this);
1219 1219
         }
1220 1220
 
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))) {
@@ -389,9 +389,9 @@  discard block
 block discarded – undo
389 389
                 if (Str::startsWith(mb_strtolower($this->subject), '=?utf-8?')) {
390 390
                     $this->subject = mb_decode_mimeheader($header->subject);
391 391
                 }
392
-            }elseif($this->config['decoder']['message']['subject'] === 'iconv') {
392
+            } elseif($this->config['decoder']['message']['subject'] === 'iconv') {
393 393
                 $this->subject = iconv_mime_decode($header->subject);
394
-            }else{
394
+            } else{
395 395
                 $this->subject = mb_decode_mimeheader($header->subject);
396 396
             }
397 397
         }
@@ -902,9 +902,9 @@  discard block
 block discarded – undo
902 902
                     return EncodingAliases::get($parameter->value, $this->fallback_encoding);
903 903
                 }
904 904
             }
905
-        }elseif (property_exists($structure, 'charset')) {
905
+        } elseif (property_exists($structure, 'charset')) {
906 906
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
907
-        }elseif (is_string($structure) === true){
907
+        } elseif (is_string($structure) === true){
908 908
             return mb_detect_encoding($structure);
909 909
         }
910 910
 
@@ -970,7 +970,9 @@  discard block
 block discarded – undo
970 970
      */
971 971
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
972 972
 
973
-        if($create_folder) $this->client->createFolder($mailbox, true);
973
+        if($create_folder) {
974
+            $this->client->createFolder($mailbox, true);
975
+        }
974 976
 
975 977
         $target_folder = $this->client->getFolder($mailbox);
976 978
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -979,7 +981,9 @@  discard block
 block discarded – undo
979 981
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
980 982
 
981 983
         if($status === true){
982
-            if($expunge) $this->client->expunge();
984
+            if($expunge) {
985
+                $this->client->expunge();
986
+            }
983 987
             $this->client->openFolder($target_folder->path);
984 988
 
985 989
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1001,7 +1005,9 @@  discard block
 block discarded – undo
1001 1005
         $this->client->openFolder($this->folder_path);
1002 1006
 
1003 1007
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1004
-        if($expunge) $this->client->expunge();
1008
+        if($expunge) {
1009
+            $this->client->expunge();
1010
+        }
1005 1011
         MessageDeletedEvent::dispatch($this);
1006 1012
 
1007 1013
         return $status;
@@ -1018,7 +1024,9 @@  discard block
 block discarded – undo
1018 1024
         $this->client->openFolder($this->folder_path);
1019 1025
 
1020 1026
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1021
-        if($expunge) $this->client->expunge();
1027
+        if($expunge) {
1028
+            $this->client->expunge();
1029
+        }
1022 1030
         MessageRestoredEvent::dispatch($this);
1023 1031
 
1024 1032
         return $status;
Please login to merge, or discard this patch.