Passed
Push — master ( ef4669...9202b0 )
by Malte
07:17 queued 02:44
created
src/IMAP/Message.php 1 patch
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,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(), 1100, $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));
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
      * @return object
673 673
      * @throws Exceptions\ConnectionFailedException
674 674
      */
675
-    private function createBody($type, $structure, $partNumber){
675
+    private function createBody($type, $structure, $partNumber) {
676 676
         return (object) [
677 677
             "type" => $type,
678 678
             "content" => $this->fetchPart($structure, $partNumber),
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
      * @return mixed|string
688 688
      * @throws Exceptions\ConnectionFailedException
689 689
      */
690
-    private function fetchPart($structure, $partNumber){
690
+    private function fetchPart($structure, $partNumber) {
691 691
         $encoding = $this->getEncoding($structure);
692 692
 
693 693
         if (!$partNumber) {
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
             }
893 893
         }elseif (property_exists($structure, 'charset')) {
894 894
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
895
-        }elseif (is_string($structure) === true){
895
+        }elseif (is_string($structure) === true) {
896 896
             return mb_detect_encoding($structure);
897 897
         }
898 898
 
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
         return null;
943 943
     }
944 944
 
945
-    public function getFolder(){
945
+    public function getFolder() {
946 946
         return $this->client->getFolder($this->folder_path);
947 947
     }
948 948
 
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
      */
959 959
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
960 960
 
961
-        if($create_folder) $this->client->createFolder($mailbox, true);
961
+        if ($create_folder) $this->client->createFolder($mailbox, true);
962 962
 
963 963
         $target_folder = $this->client->getFolder($mailbox);
964 964
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -966,8 +966,8 @@  discard block
 block discarded – undo
966 966
         $this->client->openFolder($this->folder_path);
967 967
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
968 968
 
969
-        if($status === true){
970
-            if($expunge) $this->client->expunge();
969
+        if ($status === true) {
970
+            if ($expunge) $this->client->expunge();
971 971
             $this->client->openFolder($target_folder->path);
972 972
 
973 973
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
         $this->client->openFolder($this->folder_path);
990 990
 
991 991
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
992
-        if($expunge) $this->client->expunge();
992
+        if ($expunge) $this->client->expunge();
993 993
         MessageDeletedEvent::dispatch($this);
994 994
 
995 995
         return $status;
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
         $this->client->openFolder($this->folder_path);
1007 1007
 
1008 1008
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1009
-        if($expunge) $this->client->expunge();
1009
+        if ($expunge) $this->client->expunge();
1010 1010
         MessageRestoredEvent::dispatch($this);
1011 1011
 
1012 1012
         return $status;
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
      * @return string
1084 1084
      * @throws Exceptions\ConnectionFailedException
1085 1085
      */
1086
-    public function getToken(){
1086
+    public function getToken() {
1087 1087
         return base64_encode(implode('-', [$this->message_id, $this->subject, strlen($this->getRawBody())]));
1088 1088
     }
1089 1089
 
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
     /**
1147 1147
      * @return object|null
1148 1148
      */
1149
-    public function getStructure(){
1149
+    public function getStructure() {
1150 1150
         return $this->structure;
1151 1151
     }
1152 1152
 
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
     /**
1171 1171
      * @return array
1172 1172
      */
1173
-    public function getAttributes(){
1173
+    public function getAttributes() {
1174 1174
         return $this->attributes;
1175 1175
     }
1176 1176
 
@@ -1178,8 +1178,8 @@  discard block
 block discarded – undo
1178 1178
      * @param $mask
1179 1179
      * @return $this
1180 1180
      */
1181
-    public function setMask($mask){
1182
-        if(class_exists($mask)){
1181
+    public function setMask($mask) {
1182
+        if (class_exists($mask)) {
1183 1183
             $this->mask = $mask;
1184 1184
         }
1185 1185
 
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
     /**
1190 1190
      * @return string
1191 1191
      */
1192
-    public function getMask(){
1192
+    public function getMask() {
1193 1193
         return $this->mask;
1194 1194
     }
1195 1195
 
@@ -1200,9 +1200,9 @@  discard block
 block discarded – undo
1200 1200
      * @return mixed
1201 1201
      * @throws MaskNotFoundException
1202 1202
      */
1203
-    public function mask($mask = null){
1203
+    public function mask($mask = null) {
1204 1204
         $mask = $mask !== null ? $mask : $this->mask;
1205
-        if(class_exists($mask)){
1205
+        if (class_exists($mask)) {
1206 1206
             return new $mask($this);
1207 1207
         }
1208 1208
 
Please login to merge, or discard this patch.