Passed
Push — master ( 1c981f...6990ab )
by Malte
03:43
created
src/IMAP/Message.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = false) {
190 190
 
191 191
         $default_mask = $client->getDefaultMessageMask();
192
-        if($default_mask != null) {
192
+        if ($default_mask != null) {
193 193
             $this->mask = $default_mask;
194 194
         }
195 195
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         $this->msglist = $msglist;
207 207
         $this->client = $client;
208 208
 
209
-        $this->uid =  ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
209
+        $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
210 210
         $this->msgn = ($this->fetch_options == IMAP::FT_UID) ? imap_msgno($this->client->getConnection(), $uid) : $uid;
211 211
 
212 212
         $this->parseHeader();
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
      * @throws MethodNotFoundException
230 230
      */
231 231
     public function __call($method, $arguments) {
232
-        if(strtolower(substr($method, 0, 3)) === 'get') {
232
+        if (strtolower(substr($method, 0, 3)) === 'get') {
233 233
             $name = snake_case(substr($method, 3));
234 234
 
235
-            if(isset($this->attributes[$name])) {
235
+            if (isset($this->attributes[$name])) {
236 236
                 return $this->attributes[$name];
237 237
             }
238 238
 
239 239
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
240 240
             $name = snake_case(substr($method, 3));
241 241
 
242
-            if(isset($this->attributes[$name])) {
242
+            if (isset($this->attributes[$name])) {
243 243
                 $this->attributes[$name] = array_pop($arguments);
244 244
 
245 245
                 return $this->attributes[$name];
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      * @return mixed|null
269 269
      */
270 270
     public function __get($name) {
271
-        if(isset($this->attributes[$name])) {
271
+        if (isset($this->attributes[$name])) {
272 272
             return $this->attributes[$name];
273 273
         }
274 274
 
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
         if ($replaceImages !== false) {
353 353
             $this->attachments->each(function($oAttachment) use(&$body, $replaceImages) {
354 354
                 /** @var Attachment $oAttachment */
355
-                if(is_callable($replaceImages)) {
355
+                if (is_callable($replaceImages)) {
356 356
                     $body = $replaceImages($body, $oAttachment);
357
-                }elseif(is_string($replaceImages)) {
357
+                }elseif (is_string($replaceImages)) {
358 358
                     call_user_func($replaceImages, [$body, $oAttachment]);
359
-                }else{
359
+                } else {
360 360
                     if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
361 361
                         $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
362 362
                     }
@@ -384,14 +384,14 @@  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
-            }else{
389
+            } else {
390 390
                 $this->subject = mb_decode_mimeheader($header->subject);
391 391
             }
392 392
         }
393 393
 
394
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){
394
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) {
395 395
             $this->extractHeaderAddressPart($header, $part);
396 396
         }
397 397
 
@@ -421,9 +421,9 @@  discard block
 block discarded – undo
421 421
      * @return int|null
422 422
      */
423 423
     private function extractPriority($header) {
424
-        if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){
424
+        if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) {
425 425
             $priority = isset($priority[1]) ? (int) $priority[1] : 0;
426
-            switch($priority){
426
+            switch ($priority) {
427 427
                 case IMAP::MESSAGE_PRIORITY_HIGHEST;
428 428
                     $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
429 429
                     break;
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         if (property_exists($header, 'date')) {
475 475
             $date = $header->date;
476 476
 
477
-            if(preg_match('/\+0580/', $date)) {
477
+            if (preg_match('/\+0580/', $date)) {
478 478
                 $date = str_replace('+0580', '+0530', $date);
479 479
             }
480 480
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
                         $date .= 'C';
496 496
                         break;
497 497
                 }
498
-                try{
498
+                try {
499 499
                     $parsed_date = Carbon::parse($date);
500 500
                 } catch (\Exception $_e) {
501 501
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e);
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 
518 518
         $flags = imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID);
519 519
         if (is_array($flags) && isset($flags[0])) {
520
-            foreach($this->available_flags as $flag) {
520
+            foreach ($this->available_flags as $flag) {
521 521
                 $this->parseFlag($flags, $flag);
522 522
             }
523 523
         }
@@ -614,12 +614,12 @@  discard block
 block discarded – undo
614 614
     public function parseBody() {
615 615
         $this->structure = imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID);
616 616
 
617
-        if(property_exists($this->structure, 'parts')){
617
+        if (property_exists($this->structure, 'parts')) {
618 618
             $parts = $this->structure->parts;
619 619
 
620
-            foreach ($parts as $part)  {
621
-                foreach ($part->parameters as $parameter)  {
622
-                    if($parameter->attribute == "charset")  {
620
+            foreach ($parts as $part) {
621
+                foreach ($part->parameters as $parameter) {
622
+                    if ($parameter->attribute == "charset") {
623 623
                         $encoding = $parameter->value;
624 624
 
625 625
                         $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding);
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
                     return EncodingAliases::get($parameter->value);
895 895
                 }
896 896
             }
897
-        }elseif (is_string($structure) === true){
897
+        }elseif (is_string($structure) === true) {
898 898
             return mb_detect_encoding($structure);
899 899
         }
900 900
 
@@ -956,14 +956,14 @@  discard block
 block discarded – undo
956 956
      */
957 957
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
958 958
 
959
-        if($create_folder) $this->client->createFolder($mailbox, true);
959
+        if ($create_folder) $this->client->createFolder($mailbox, true);
960 960
 
961 961
         $target_folder = $this->client->getFolder($mailbox);
962 962
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
963 963
 
964 964
         $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
965
-        if($status === true){
966
-            if($expunge) $this->client->expunge();
965
+        if ($status === true) {
966
+            if ($expunge) $this->client->expunge();
967 967
 
968 968
             return $target_folder->getMessage($target_status->uidnext);
969 969
         }
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
      */
981 981
     public function delete($expunge = true) {
982 982
         $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
983
-        if($expunge) $this->client->expunge();
983
+        if ($expunge) $this->client->expunge();
984 984
 
985 985
         return $status;
986 986
     }
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
      */
995 995
     public function restore($expunge = true) {
996 996
         $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
997
-        if($expunge) $this->client->expunge();
997
+        if ($expunge) $this->client->expunge();
998 998
 
999 999
         return $status;
1000 1000
     }
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
     /**
1119 1119
      * @return object|null
1120 1120
      */
1121
-    public function getStructure(){
1121
+    public function getStructure() {
1122 1122
         return $this->structure;
1123 1123
     }
1124 1124
 
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
     /**
1145 1145
      * @return array
1146 1146
      */
1147
-    public function getAttributes(){
1147
+    public function getAttributes() {
1148 1148
         return $this->attributes;
1149 1149
     }
1150 1150
 
@@ -1152,8 +1152,8 @@  discard block
 block discarded – undo
1152 1152
      * @param $mask
1153 1153
      * @return $this
1154 1154
      */
1155
-    public function setMask($mask){
1156
-        if(class_exists($mask)){
1155
+    public function setMask($mask) {
1156
+        if (class_exists($mask)) {
1157 1157
             $this->mask = $mask;
1158 1158
         }
1159 1159
 
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
     /**
1164 1164
      * @return string
1165 1165
      */
1166
-    public function getMask(){
1166
+    public function getMask() {
1167 1167
         return $this->mask;
1168 1168
     }
1169 1169
 
@@ -1174,9 +1174,9 @@  discard block
 block discarded – undo
1174 1174
      * @return mixed
1175 1175
      * @throws MaskNotFoundException
1176 1176
      */
1177
-    public function mask($mask = null){
1177
+    public function mask($mask = null) {
1178 1178
         $mask = $mask !== null ? $mask : $this->mask;
1179
-        if(class_exists($mask)){
1179
+        if (class_exists($mask)) {
1180 1180
             return new $mask($this);
1181 1181
         }
1182 1182
 
Please login to merge, or discard this patch.
Braces   +17 added lines, -9 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
                 return $this->attributes[$name];
237 237
             }
238 238
 
239
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
239
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
240 240
             $name = snake_case(substr($method, 3));
241 241
 
242 242
             if(isset($this->attributes[$name])) {
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
                 /** @var Attachment $oAttachment */
355 355
                 if(is_callable($replaceImages)) {
356 356
                     $body = $replaceImages($body, $oAttachment);
357
-                }elseif(is_string($replaceImages)) {
357
+                } elseif(is_string($replaceImages)) {
358 358
                     call_user_func($replaceImages, [$body, $oAttachment]);
359
-                }else{
359
+                } else{
360 360
                     if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
361 361
                         $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
362 362
                     }
@@ -386,7 +386,7 @@  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
-            }else{
389
+            } else{
390 390
                 $this->subject = mb_decode_mimeheader($header->subject);
391 391
             }
392 392
         }
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
                     return EncodingAliases::get($parameter->value);
895 895
                 }
896 896
             }
897
-        }elseif (is_string($structure) === true){
897
+        } elseif (is_string($structure) === true){
898 898
             return mb_detect_encoding($structure);
899 899
         }
900 900
 
@@ -956,14 +956,18 @@  discard block
 block discarded – undo
956 956
      */
957 957
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
958 958
 
959
-        if($create_folder) $this->client->createFolder($mailbox, true);
959
+        if($create_folder) {
960
+            $this->client->createFolder($mailbox, true);
961
+        }
960 962
 
961 963
         $target_folder = $this->client->getFolder($mailbox);
962 964
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
963 965
 
964 966
         $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
965 967
         if($status === true){
966
-            if($expunge) $this->client->expunge();
968
+            if($expunge) {
969
+                $this->client->expunge();
970
+            }
967 971
 
968 972
             return $target_folder->getMessage($target_status->uidnext);
969 973
         }
@@ -980,7 +984,9 @@  discard block
 block discarded – undo
980 984
      */
981 985
     public function delete($expunge = true) {
982 986
         $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
983
-        if($expunge) $this->client->expunge();
987
+        if($expunge) {
988
+            $this->client->expunge();
989
+        }
984 990
 
985 991
         return $status;
986 992
     }
@@ -994,7 +1000,9 @@  discard block
 block discarded – undo
994 1000
      */
995 1001
     public function restore($expunge = true) {
996 1002
         $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
997
-        if($expunge) $this->client->expunge();
1003
+        if($expunge) {
1004
+            $this->client->expunge();
1005
+        }
998 1006
 
999 1007
         return $status;
1000 1008
     }
Please login to merge, or discard this patch.