Completed
Push — master ( 2c2bb8...3cab00 )
by Malte
02:14
created
src/Message.php 1 patch
Spacing   +44 added lines, -44 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_flags = false, $sequence = 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
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         if ($this->sequence === IMAP::ST_UID) {
226 226
             $this->uid = $uid;
227 227
             $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid);
228
-        }else{
228
+        }else {
229 229
             $this->msgn = $uid;
230 230
             $this->uid = $this->client->getConnection()->getUid($this->msgn);
231 231
         }
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
      * @throws MessageContentFetchingException
266 266
      * @throws \ReflectionException
267 267
      */
268
-    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){
268
+    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) {
269 269
         $reflection = new \ReflectionClass(self::class);
270 270
         /** @var self $instance */
271 271
         $instance = $reflection->newInstanceWithoutConstructor();
272 272
 
273 273
         $default_mask = $client->getDefaultMessageMask();
274
-        if($default_mask != null) {
274
+        if ($default_mask != null) {
275 275
             $instance->setMask($default_mask);
276 276
         }
277 277
         $instance->setEvents([
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         if ($instance->getSequence() === IMAP::ST_UID) {
292 292
             $instance->setUid($uid);
293 293
             $instance->setMsglist($msglist);
294
-        }else{
294
+        }else {
295 295
             $instance->setMsgn($uid, $msglist);
296 296
         }
297 297
 
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
      * @throws MethodNotFoundException
320 320
      */
321 321
     public function __call($method, $arguments) {
322
-        if(strtolower(substr($method, 0, 3)) === 'get') {
322
+        if (strtolower(substr($method, 0, 3)) === 'get') {
323 323
             $name = Str::snake(substr($method, 3));
324 324
             return $this->get($name);
325 325
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
326 326
             $name = Str::snake(substr($method, 3));
327 327
 
328
-            if(in_array($name, array_keys($this->attributes))) {
328
+            if (in_array($name, array_keys($this->attributes))) {
329 329
                 $this->attributes[$name] = array_pop($arguments);
330 330
 
331 331
                 return $this->attributes[$name];
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
      * @return mixed|null
367 367
      */
368 368
     public function get($name) {
369
-        if(isset($this->attributes[$name])) {
369
+        if (isset($this->attributes[$name])) {
370 370
             return $this->attributes[$name];
371 371
         }
372 372
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
      *
441 441
      * @throws InvalidMessageDateException
442 442
      */
443
-    public function parseRawHeader($raw_header){
443
+    public function parseRawHeader($raw_header) {
444 444
         $this->header = new Header($raw_header);
445 445
     }
446 446
 
@@ -451,8 +451,8 @@  discard block
 block discarded – undo
451 451
     public function parseRawFlags($raw_flags) {
452 452
         $this->flags = FlagCollection::make([]);
453 453
 
454
-        foreach($raw_flags as $flag) {
455
-            if (strpos($flag, "\\") === 0){
454
+        foreach ($raw_flags as $flag) {
455
+            if (strpos($flag, "\\") === 0) {
456 456
                 $flag = substr($flag, 1);
457 457
             }
458 458
             $flag_key = strtolower($flag);
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 
556 556
         if ($part->isAttachment()) {
557 557
             $this->fetchAttachment($part);
558
-        }else{
558
+        }else {
559 559
             $encoding = $this->getEncoding($part);
560 560
 
561 561
             $content = $this->decodeString($part->content, $part->encoding);
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
         if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) {
594 594
             if ($oAttachment->getId() !== null) {
595 595
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
596
-            } else {
596
+            }else {
597 597
                 $this->attachments->push($oAttachment);
598 598
             }
599 599
         }
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 
728 728
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
729 729
             return @iconv($from, $to.'//IGNORE', $str);
730
-        } else {
730
+        }else {
731 731
             if (!$from) {
732 732
                 return mb_convert_encoding($str, $to);
733 733
             }
@@ -748,9 +748,9 @@  discard block
 block discarded – undo
748 748
                     return EncodingAliases::get($parameter->value);
749 749
                 }
750 750
             }
751
-        }elseif (property_exists($structure, 'charset')){
751
+        }elseif (property_exists($structure, 'charset')) {
752 752
             return EncodingAliases::get($structure->charset);
753
-        }elseif (is_string($structure) === true){
753
+        }elseif (is_string($structure) === true) {
754 754
             return mb_detect_encoding($structure);
755 755
         }
756 756
 
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
      * @throws Exceptions\ConnectionFailedException
765 765
      * @throws Exceptions\FolderFetchingException
766 766
      */
767
-    public function getFolder(){
767
+    public function getFolder() {
768 768
         return $this->client->getFolder($this->folder_path);
769 769
     }
770 770
 
@@ -779,13 +779,13 @@  discard block
 block discarded – undo
779 779
      * @throws Exceptions\FolderFetchingException
780 780
      * @throws Exceptions\GetMessagesFailedException
781 781
      */
782
-    public function thread($sent_folder = null, &$thread = null, $folder = null){
782
+    public function thread($sent_folder = null, &$thread = null, $folder = null) {
783 783
         $thread = $thread ? $thread : MessageCollection::make([]);
784
-        $folder = $folder ? $folder :  $this->getFolder();
784
+        $folder = $folder ? $folder : $this->getFolder();
785 785
         $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
786 786
 
787 787
         /** @var Message $message */
788
-        foreach($thread as $message) {
788
+        foreach ($thread as $message) {
789 789
             if ($message->message_id == $this->message_id) {
790 790
                 return $thread;
791 791
             }
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
         });
807 807
 
808 808
         if (is_array($this->in_reply_to)) {
809
-            foreach($this->in_reply_to as $in_reply_to) {
809
+            foreach ($this->in_reply_to as $in_reply_to) {
810 810
                 $folder->query()->messageId($in_reply_to)
811 811
                     ->setFetchBody($this->getFetchBodyOption())
812 812
                     ->leaveUnread()->get()->each(function($message) use(&$thread, $folder, $sent_folder){
@@ -851,13 +851,13 @@  discard block
 block discarded – undo
851 851
 
852 852
             $this->client->openFolder($this->folder_path);
853 853
             if ($this->client->getConnection()->copyMessage($folder->path, $this->getSequenceId(), null, $this->sequence === IMAP::ST_UID) == true) {
854
-                if($expunge) $this->client->expunge();
854
+                if ($expunge) $this->client->expunge();
855 855
 
856 856
                 $this->client->openFolder($folder->path);
857 857
 
858 858
                 if ($this->sequence === IMAP::ST_UID) {
859 859
                     $sequence_id = $next_uid;
860
-                }else{
860
+                }else {
861 861
                     $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
862 862
                 }
863 863
 
@@ -898,13 +898,13 @@  discard block
 block discarded – undo
898 898
 
899 899
             $this->client->openFolder($this->folder_path);
900 900
             if ($this->client->getConnection()->moveMessage($folder->path, $this->getSequenceId(), null, $this->sequence === IMAP::ST_UID) == true) {
901
-                if($expunge) $this->client->expunge();
901
+                if ($expunge) $this->client->expunge();
902 902
 
903 903
                 $this->client->openFolder($folder->path);
904 904
 
905 905
                 if ($this->sequence === IMAP::ST_UID) {
906 906
                     $sequence_id = $next_uid;
907
-                }else{
907
+                }else {
908 908
                     $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
909 909
                 }
910 910
 
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
      */
931 931
     public function delete($expunge = true) {
932 932
         $status = $this->setFlag("Deleted");
933
-        if($expunge) $this->client->expunge();
933
+        if ($expunge) $this->client->expunge();
934 934
 
935 935
         $event = $this->getEvent("message", "deleted");
936 936
         $event::dispatch($this);
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
      */
950 950
     public function restore($expunge = true) {
951 951
         $status = $this->unsetFlag("Deleted");
952
-        if($expunge) $this->client->expunge();
952
+        if ($expunge) $this->client->expunge();
953 953
 
954 954
         $event = $this->getEvent("message", "restored");
955 955
         $event::dispatch($this);
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
      *
1105 1105
      * @return Structure|null
1106 1106
      */
1107
-    public function getStructure(){
1107
+    public function getStructure() {
1108 1108
         return $this->structure;
1109 1109
     }
1110 1110
 
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
      *
1131 1131
      * @return array
1132 1132
      */
1133
-    public function getAttributes(){
1133
+    public function getAttributes() {
1134 1134
         return array_merge($this->attributes, $this->header->getAttributes());
1135 1135
     }
1136 1136
 
@@ -1140,8 +1140,8 @@  discard block
 block discarded – undo
1140 1140
      *
1141 1141
      * @return $this
1142 1142
      */
1143
-    public function setMask($mask){
1144
-        if(class_exists($mask)){
1143
+    public function setMask($mask) {
1144
+        if (class_exists($mask)) {
1145 1145
             $this->mask = $mask;
1146 1146
         }
1147 1147
 
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
      *
1154 1154
      * @return string
1155 1155
      */
1156
-    public function getMask(){
1156
+    public function getMask() {
1157 1157
         return $this->mask;
1158 1158
     }
1159 1159
 
@@ -1164,9 +1164,9 @@  discard block
 block discarded – undo
1164 1164
      * @return mixed
1165 1165
      * @throws MaskNotFoundException
1166 1166
      */
1167
-    public function mask($mask = null){
1167
+    public function mask($mask = null) {
1168 1168
         $mask = $mask !== null ? $mask : $this->mask;
1169
-        if(class_exists($mask)){
1169
+        if (class_exists($mask)) {
1170 1170
             return new $mask($this);
1171 1171
         }
1172 1172
 
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
      *
1180 1180
      * @return $this
1181 1181
      */
1182
-    public function setFolderPath($folder_path){
1182
+    public function setFolderPath($folder_path) {
1183 1183
         $this->folder_path = $folder_path;
1184 1184
 
1185 1185
         return $this;
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
      *
1192 1192
      * @return $this
1193 1193
      */
1194
-    public function setConfig($config){
1194
+    public function setConfig($config) {
1195 1195
         $this->config = $config;
1196 1196
 
1197 1197
         return $this;
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
      *
1204 1204
      * @return $this
1205 1205
      */
1206
-    public function setAvailableFlags($available_flags){
1206
+    public function setAvailableFlags($available_flags) {
1207 1207
         $this->available_flags = $available_flags;
1208 1208
 
1209 1209
         return $this;
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
      *
1216 1216
      * @return $this
1217 1217
      */
1218
-    public function setAttachments($attachments){
1218
+    public function setAttachments($attachments) {
1219 1219
         $this->attachments = $attachments;
1220 1220
 
1221 1221
         return $this;
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
      *
1228 1228
      * @return $this
1229 1229
      */
1230
-    public function setFlags($flags){
1230
+    public function setFlags($flags) {
1231 1231
         $this->flags = $flags;
1232 1232
 
1233 1233
         return $this;
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
      * @throws Exceptions\ConnectionFailedException
1241 1241
      * @return $this
1242 1242
      */
1243
-    public function setClient($client){
1243
+    public function setClient($client) {
1244 1244
         $this->client = $client;
1245 1245
         $this->client->openFolder($this->folder_path);
1246 1246
 
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
      * @throws Exceptions\RuntimeException
1256 1256
      * @return $this
1257 1257
      */
1258
-    public function setUid($uid){
1258
+    public function setUid($uid) {
1259 1259
         $this->uid = $uid;
1260 1260
         $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid);
1261 1261
         $this->msglist = null;
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
      * @throws Exceptions\RuntimeException
1273 1273
      * @return $this
1274 1274
      */
1275
-    public function setMsgn($msgn, $msglist = null){
1275
+    public function setMsgn($msgn, $msglist = null) {
1276 1276
         $this->msgn = $msgn;
1277 1277
         $this->msglist = $msglist;
1278 1278
         $this->uid = $this->client->getConnection()->getUid($this->msgn);
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
      *
1286 1286
      * @return int
1287 1287
      */
1288
-    public function getSequence(){
1288
+    public function getSequence() {
1289 1289
         return $this->sequence;
1290 1290
     }
1291 1291
 
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
      *
1295 1295
      * @return int
1296 1296
      */
1297
-    public function getSequenceId(){
1297
+    public function getSequenceId() {
1298 1298
         return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn;
1299 1299
     }
1300 1300
 }
Please login to merge, or discard this patch.