Completed
Push — master ( e60d4a...ff1a39 )
by Malte
02:24
created
src/Attribute.php 2 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     public function add($value, $strict = false) {
75 75
         if (is_array($value)) {
76 76
             return $this->merge($value, $strict);
77
-        }elseif ($value !== null) {
77
+        } elseif ($value !== null) {
78 78
             $this->attach($value, $strict);
79 79
         }
80 80
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             if ($this->contains($value) === false) {
124 124
                 $this->values[] = $value;
125 125
             }
126
-        }else{
126
+        } else{
127 127
             $this->values[] = $value;
128 128
         }
129 129
     }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      *
61 61
      * @return string
62 62
      */
63
-    public function toString(){
63
+    public function toString() {
64 64
         return $this->__toString();
65 65
     }
66 66
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      *
70 70
      * @return array
71 71
      */
72
-    public function __serialize(){
72
+    public function __serialize() {
73 73
         return $this->values;
74 74
     }
75 75
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      *
79 79
      * @return array
80 80
      */
81
-    public function toArray(){
81
+    public function toArray() {
82 82
         return $this->__serialize();
83 83
     }
84 84
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             if ($this->contains($value) === false) {
142 142
                 $this->values[] = $value;
143 143
             }
144
-        }else{
144
+        }else {
145 145
             $this->values[] = $value;
146 146
         }
147 147
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @return Attribute
154 154
      */
155
-    public function setName($name){
155
+    public function setName($name) {
156 156
         $this->name = $name;
157 157
 
158 158
         return $this;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      *
164 164
      * @return string
165 165
      */
166
-    public function getName(){
166
+    public function getName() {
167 167
         return $this->name;
168 168
     }
169 169
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      *
173 173
      * @return array
174 174
      */
175
-    public function get(){
175
+    public function get() {
176 176
         return $this->values;
177 177
     }
178 178
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      *
182 182
      * @return array
183 183
      */
184
-    public function all(){
184
+    public function all() {
185 185
         return $this->get();
186 186
     }
187 187
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      *
191 191
      * @return mixed|null
192 192
      */
193
-    public function first(){
193
+    public function first() {
194 194
         if (count($this->values) > 0) {
195 195
             return $this->values[0];
196 196
         }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      *
203 203
      * @return mixed|null
204 204
      */
205
-    public function last(){
205
+    public function last() {
206 206
         $cnt = count($this->values);
207 207
         if ($cnt > 0) {
208 208
             return $this->values[$cnt - 1];
Please login to merge, or discard this patch.
src/Header.php 2 patches
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
      * @throws MethodNotFoundException
74 74
      */
75 75
     public function __call($method, $arguments) {
76
-        if(strtolower(substr($method, 0, 3)) === 'get') {
76
+        if (strtolower(substr($method, 0, 3)) === 'get') {
77 77
             $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3));
78 78
 
79
-            if(in_array($name, array_keys($this->attributes))) {
79
+            if (in_array($name, array_keys($this->attributes))) {
80 80
                 return $this->attributes[$name];
81 81
             }
82 82
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @return Attribute|null
103 103
      */
104 104
     public function get($name) {
105
-        if(isset($this->attributes[$name])) {
105
+        if (isset($this->attributes[$name])) {
106 106
             return $this->attributes[$name];
107 107
         }
108 108
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
      * @return Attribute
119 119
      */
120 120
     public function set($name, $value, $strict = false) {
121
-        if(isset($this->attributes[$name]) && $strict === false) {
121
+        if (isset($this->attributes[$name]) && $strict === false) {
122 122
             $this->attributes[$name]->add($value, true);
123
-        }else{
123
+        }else {
124 124
             $this->attributes[$name] = new Attribute($name, $value);
125 125
         }
126 126
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     public function find($pattern) {
137 137
         if (preg_match_all($pattern, $this->raw, $matches)) {
138 138
             if (isset($matches[1])) {
139
-                if(count($matches[1]) > 0) {
139
+                if (count($matches[1]) > 0) {
140 140
                     return $matches[1][0];
141 141
                 }
142 142
             }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      *
150 150
      * @throws InvalidMessageDateException
151 151
      */
152
-    protected function parse(){
152
+    protected function parse() {
153 153
         $header = $this->rfc822_parse_headers($this->raw);
154 154
 
155 155
         $this->extractAddresses($header);
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $this->parseDate($header);
168 168
         foreach ($header as $key => $value) {
169 169
             $key = trim(rtrim(strtolower($key)));
170
-            if(!isset($this->attributes[$key])){
170
+            if (!isset($this->attributes[$key])) {
171 171
                 $this->set($key, $value);
172 172
             }
173 173
         }
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
      *
184 184
      * @return object
185 185
      */
186
-    public function rfc822_parse_headers($raw_headers){
186
+    public function rfc822_parse_headers($raw_headers) {
187 187
         $headers = [];
188 188
         $imap_headers = [];
189 189
         if (extension_loaded('imap')) {
190 190
             $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw);
191
-            foreach($raw_imap_headers as $key => $values) {
191
+            foreach ($raw_imap_headers as $key => $values) {
192 192
                 $key = str_replace("-", "_", $key);
193 193
                 $imap_headers[$key] = $values;
194 194
             }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
         $lines = explode("\r\n", $raw_headers);
198 198
         $prev_header = null;
199
-        foreach($lines as $line) {
199
+        foreach ($lines as $line) {
200 200
             if (substr($line, 0, 1) === "\n") {
201 201
                 $line = substr($line, 1);
202 202
             }
@@ -216,19 +216,19 @@  discard block
 block discarded – undo
216 216
                     }
217 217
                     if (is_array($headers[$prev_header])) {
218 218
                         $headers[$prev_header][] = $line;
219
-                    }else{
219
+                    }else {
220 220
                         $headers[$prev_header] .= $line;
221 221
                     }
222 222
                 }
223
-            }else{
223
+            }else {
224 224
                 if (($pos = strpos($line, ":")) > 0) {
225 225
                     $key = trim(rtrim(strtolower(substr($line, 0, $pos))));
226 226
                     $key = str_replace("-", "_", $key);
227 227
 
228 228
                     $value = trim(rtrim(substr($line, $pos + 1)));
229 229
                     if (isset($headers[$key])) {
230
-                        $headers[$key][]  = $value;
231
-                    }else{
230
+                        $headers[$key][] = $value;
231
+                    }else {
232 232
                         $headers[$key] = [$value];
233 233
                     }
234 234
                     $prev_header = $key;
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
             }
237 237
         }
238 238
 
239
-        foreach($headers as $key => $values) {
239
+        foreach ($headers as $key => $values) {
240 240
             if (isset($imap_headers[$key])) continue;
241 241
             $value = null;
242
-            switch($key){
242
+            switch ($key) {
243 243
                 case 'from':
244 244
                 case 'to':
245 245
                 case 'cc':
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                     break;
255 255
                 default:
256 256
                     if (is_array($values)) {
257
-                        foreach($values as $k => $v) {
257
+                        foreach ($values as $k => $v) {
258 258
                             if ($v == "") {
259 259
                                 unset($values[$k]);
260 260
                             }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
                             $value = implode(" ", $values);
267 267
                         } elseif ($available_values > 2) {
268 268
                             $value = array_values($values);
269
-                        } else {
269
+                        }else {
270 270
                             $value = "";
271 271
                         }
272 272
                     }
@@ -286,12 +286,12 @@  discard block
 block discarded – undo
286 286
      * @return array The decoded elements are returned in an array of objects, where each
287 287
      * object has two properties, charset and text.
288 288
      */
289
-    public function mime_header_decode($text){
289
+    public function mime_header_decode($text) {
290 290
         if (extension_loaded('imap')) {
291 291
             return \imap_mime_header_decode($text);
292 292
         }
293 293
         $charset = $this->getEncoding($text);
294
-        return [(object)[
294
+        return [(object) [
295 295
             "charset" => $charset,
296 296
             "text" => $this->convertEncoding($text, $charset)
297 297
         ]];
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         try {
346 346
             if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
347 347
                 return iconv($from, $to, $str);
348
-            } else {
348
+            }else {
349 349
                 if (!$from) {
350 350
                     return mb_convert_encoding($str, $to);
351 351
                 }
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
             if (strstr($from, '-')) {
356 356
                 $from = str_replace('-', '', $from);
357 357
                 return $this->convertEncoding($str, $from, $to);
358
-            } else {
358
+            }else {
359 359
                 return $str;
360 360
             }
361 361
         }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
             }
377 377
         }elseif (property_exists($structure, 'charset')) {
378 378
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
379
-        }elseif (is_string($structure) === true){
379
+        }elseif (is_string($structure) === true) {
380 380
             return mb_detect_encoding($structure);
381 381
         }
382 382
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
         $decoder = $this->config['decoder']['message'];
398 398
 
399 399
         if ($value !== null) {
400
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
400
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
401 401
                 $value = \imap_utf8($value);
402 402
                 if (strpos(strtolower($value), '=?utf-8?') === 0) {
403 403
                     $value = mb_decode_mimeheader($value);
@@ -405,14 +405,14 @@  discard block
 block discarded – undo
405 405
                 if ($this->notDecoded($original_value, $value)) {
406 406
                     $decoded_value = $this->mime_header_decode($value);
407 407
                     if (count($decoded_value) > 0) {
408
-                        if(property_exists($decoded_value[0], "text")) {
408
+                        if (property_exists($decoded_value[0], "text")) {
409 409
                             $value = $decoded_value[0]->text;
410 410
                         }
411 411
                     }
412 412
                 }
413
-            }elseif($decoder === 'iconv') {
413
+            }elseif ($decoder === 'iconv') {
414 414
                 $value = iconv_mime_decode($value);
415
-            }else{
415
+            }else {
416 416
                 $value = mb_decode_mimeheader($value);
417 417
             }
418 418
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
      * @return array
436 436
      */
437 437
     private function decodeArray($values) {
438
-        foreach($values as $key => $value) {
438
+        foreach ($values as $key => $value) {
439 439
             $values[$key] = $this->decode($value);
440 440
         }
441 441
         return $values;
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
      * Try to extract the priority from a given raw header string
446 446
      */
447 447
     private function findPriority() {
448
-        if(($priority = $this->get("x_priority")) === null) return;
449
-        switch((int)"$priority"){
448
+        if (($priority = $this->get("x_priority")) === null) return;
449
+        switch ((int) "$priority") {
450 450
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
451 451
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
452 452
                 break;
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
      */
479 479
     private function decodeAddresses($values) {
480 480
         $addresses = [];
481
-        foreach($values as $address) {
481
+        foreach ($values as $address) {
482 482
             $address = trim(rtrim($address));
483 483
             if (strpos($address, ",") == strlen($address) - 1) {
484 484
                 $address = substr($address, 0, -1);
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
                 '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/',
488 488
                 $address,
489 489
                 $matches
490
-            )){
490
+            )) {
491 491
                 $name = trim(rtrim($matches["name"]));
492 492
                 $email = trim(rtrim($matches["email"]));
493 493
                 list($mailbox, $host) = array_pad(explode("@", $email), 2, null);
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
      * @param object $header
507 507
      */
508 508
     private function extractAddresses($header) {
509
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){
509
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) {
510 510
             if (property_exists($header, $key)) {
511 511
                 $this->set($key, $this->parseAddresses($header->$key));
512 512
             }
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
             }
538 538
             if (!property_exists($address, 'personal')) {
539 539
                 $address->personal = false;
540
-            } else {
540
+            }else {
541 541
                 $personalParts = $this->mime_header_decode($address->personal);
542 542
 
543
-                if(is_array($personalParts)) {
543
+                if (is_array($personalParts)) {
544 544
                     $address->personal = '';
545 545
                     foreach ($personalParts as $p) {
546 546
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -564,19 +564,19 @@  discard block
 block discarded – undo
564 564
     /**
565 565
      * Search and extract potential header extensions
566 566
      */
567
-    private function extractHeaderExtensions(){
567
+    private function extractHeaderExtensions() {
568 568
         foreach ($this->attributes as $key => $value) {
569
-            $value = (string)$value;
569
+            $value = (string) $value;
570 570
             // Only parse strings and don't parse any attributes like the user-agent
571 571
             if (in_array($key, ["user_agent"]) === false) {
572
-                if (($pos = strpos($value, ";")) !== false){
572
+                if (($pos = strpos($value, ";")) !== false) {
573 573
                     $original = substr($value, 0, $pos);
574 574
                     $this->set($key, trim(rtrim($original)), true);
575 575
 
576 576
                     // Get all potential extensions
577 577
                     $extensions = explode(";", substr($value, $pos + 1));
578
-                    foreach($extensions as $extension) {
579
-                        if (($pos = strpos($extension, "=")) !== false){
578
+                    foreach ($extensions as $extension) {
579
+                        if (($pos = strpos($extension, "=")) !== false) {
580 580
                             $key = substr($extension, 0, $pos);
581 581
                             $key = trim(rtrim(strtolower($key)));
582 582
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
             $parsed_date = null;
620 620
             $date = $header->date;
621 621
 
622
-            if(preg_match('/\+0580/', $date)) {
622
+            if (preg_match('/\+0580/', $date)) {
623 623
                 $date = str_replace('+0580', '+0530', $date);
624 624
             }
625 625
 
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
                         $date = trim(array_pop($array));
643 643
                         break;
644 644
                 }
645
-                try{
645
+                try {
646 646
                     $parsed_date = Carbon::parse($date);
647 647
                 } catch (\Exception $_e) {
648 648
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e);
Please login to merge, or discard this patch.
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     public function set($name, $value, $strict = false) {
121 121
         if(isset($this->attributes[$name]) && $strict === false) {
122 122
             $this->attributes[$name]->add($value, true);
123
-        }else{
123
+        } else{
124 124
             $this->attributes[$name] = new Attribute($name, $value);
125 125
         }
126 126
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
                 if ($prev_header !== null) {
208 208
                     $headers[$prev_header][] = $line;
209 209
                 }
210
-            }elseif (substr($line, 0, 1) === " ") {
210
+            } elseif (substr($line, 0, 1) === " ") {
211 211
                 $line = substr($line, 1);
212 212
                 $line = trim(rtrim($line));
213 213
                 if ($prev_header !== null) {
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
                     }
217 217
                     if (is_array($headers[$prev_header])) {
218 218
                         $headers[$prev_header][] = $line;
219
-                    }else{
219
+                    } else{
220 220
                         $headers[$prev_header] .= $line;
221 221
                     }
222 222
                 }
223
-            }else{
223
+            } else{
224 224
                 if (($pos = strpos($line, ":")) > 0) {
225 225
                     $key = trim(rtrim(strtolower(substr($line, 0, $pos))));
226 226
                     $key = str_replace("-", "_", $key);
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                     $value = trim(rtrim(substr($line, $pos + 1)));
229 229
                     if (isset($headers[$key])) {
230 230
                         $headers[$key][]  = $value;
231
-                    }else{
231
+                    } else{
232 232
                         $headers[$key] = [$value];
233 233
                     }
234 234
                     $prev_header = $key;
@@ -237,7 +237,9 @@  discard block
 block discarded – undo
237 237
         }
238 238
 
239 239
         foreach($headers as $key => $values) {
240
-            if (isset($imap_headers[$key])) continue;
240
+            if (isset($imap_headers[$key])) {
241
+                continue;
242
+            }
241 243
             $value = null;
242 244
             switch($key){
243 245
                 case 'from':
@@ -374,9 +376,9 @@  discard block
 block discarded – undo
374 376
                     return EncodingAliases::get($parameter->value, $this->fallback_encoding);
375 377
                 }
376 378
             }
377
-        }elseif (property_exists($structure, 'charset')) {
379
+        } elseif (property_exists($structure, 'charset')) {
378 380
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
379
-        }elseif (is_string($structure) === true){
381
+        } elseif (is_string($structure) === true){
380 382
             return mb_detect_encoding($structure);
381 383
         }
382 384
 
@@ -410,9 +412,9 @@  discard block
 block discarded – undo
410 412
                         }
411 413
                     }
412 414
                 }
413
-            }elseif($decoder === 'iconv') {
415
+            } elseif($decoder === 'iconv') {
414 416
                 $value = iconv_mime_decode($value);
415
-            }else{
417
+            } else{
416 418
                 $value = mb_decode_mimeheader($value);
417 419
             }
418 420
 
@@ -445,7 +447,9 @@  discard block
 block discarded – undo
445 447
      * Try to extract the priority from a given raw header string
446 448
      */
447 449
     private function findPriority() {
448
-        if(($priority = $this->get("x_priority")) === null) return;
450
+        if(($priority = $this->get("x_priority")) === null) {
451
+            return;
452
+        }
449 453
         switch((int)"$priority"){
450 454
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
451 455
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
Please login to merge, or discard this patch.
src/Message.php 2 patches
Braces   +16 added lines, -10 removed lines patch added patch discarded remove patch
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
         if(strtolower(substr($method, 0, 3)) === 'get') {
306 306
             $name = Str::snake(substr($method, 3));
307 307
             return $this->get($name);
308
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
308
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
309 309
             $name = Str::snake(substr($method, 3));
310 310
 
311 311
             if(in_array($name, array_keys($this->attributes))) {
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
             if ($this->getFlags()->get("seen") == null) {
509 509
                 $this->unsetFlag("Seen");
510 510
             }
511
-        }elseif ($this->getFlags()->get("seen") != null) {
511
+        } elseif ($this->getFlags()->get("seen") != null) {
512 512
             $this->setFlag("Seen");
513 513
         }
514 514
     }
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
     private function fetchPart(Part $part) {
551 551
         if ($part->isAttachment()) {
552 552
             $this->fetchAttachment($part);
553
-        }else{
553
+        } else{
554 554
             $encoding = $this->getEncoding($part);
555 555
 
556 556
             $content = $this->decodeString($part->content, $part->encoding);
@@ -742,9 +742,9 @@  discard block
 block discarded – undo
742 742
                     return EncodingAliases::get($parameter->value);
743 743
                 }
744 744
             }
745
-        }elseif (property_exists($structure, 'charset')){
745
+        } elseif (property_exists($structure, 'charset')){
746 746
             return EncodingAliases::get($structure->charset);
747
-        }elseif (is_string($structure) === true){
747
+        } elseif (is_string($structure) === true){
748 748
             return mb_detect_encoding($structure);
749 749
         }
750 750
 
@@ -924,13 +924,15 @@  discard block
 block discarded – undo
924 924
      * @throws MessageHeaderFetchingException
925 925
      */
926 926
     protected function fetchNewMail($folder, $next_uid, $event, $expunge){
927
-        if($expunge) $this->client->expunge();
927
+        if($expunge) {
928
+            $this->client->expunge();
929
+        }
928 930
 
929 931
         $this->client->openFolder($folder->path);
930 932
 
931 933
         if ($this->sequence === IMAP::ST_UID) {
932 934
             $sequence_id = $next_uid;
933
-        }else{
935
+        } else{
934 936
             $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
935 937
         }
936 938
 
@@ -952,7 +954,9 @@  discard block
 block discarded – undo
952 954
      */
953 955
     public function delete($expunge = true) {
954 956
         $status = $this->setFlag("Deleted");
955
-        if($expunge) $this->client->expunge();
957
+        if($expunge) {
958
+            $this->client->expunge();
959
+        }
956 960
 
957 961
         $event = $this->getEvent("message", "deleted");
958 962
         $event::dispatch($this);
@@ -971,7 +975,9 @@  discard block
 block discarded – undo
971 975
      */
972 976
     public function restore($expunge = true) {
973 977
         $status = $this->unsetFlag("Deleted");
974
-        if($expunge) $this->client->expunge();
978
+        if($expunge) {
979
+            $this->client->expunge();
980
+        }
975 981
 
976 982
         $event = $this->getEvent("message", "restored");
977 983
         $event::dispatch($this);
@@ -1384,7 +1390,7 @@  discard block
 block discarded – undo
1384 1390
         if ($this->getSequence() === IMAP::ST_UID) {
1385 1391
             $this->setUid($uid);
1386 1392
             $this->setMsglist($msglist);
1387
-        }else{
1393
+        } else{
1388 1394
             $this->setMsgn($uid, $msglist);
1389 1395
         }
1390 1396
     }
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false, $sequence = null) {
203 203
 
204 204
         $default_mask = $client->getDefaultMessageMask();
205
-        if($default_mask != null) {
205
+        if ($default_mask != null) {
206 206
             $this->mask = $default_mask;
207 207
         }
208 208
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
      * @throws MessageFlagException
262 262
      * @throws Exceptions\RuntimeException
263 263
      */
264
-    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){
264
+    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) {
265 265
         $reflection = new \ReflectionClass(self::class);
266 266
         /** @var self $instance */
267 267
         $instance = $reflection->newInstanceWithoutConstructor();
268 268
 
269 269
         $default_mask = $client->getDefaultMessageMask();
270
-        if($default_mask != null) {
270
+        if ($default_mask != null) {
271 271
             $instance->setMask($default_mask);
272 272
         }
273 273
         $instance->setEvents([
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
      * @throws MethodNotFoundException
303 303
      */
304 304
     public function __call($method, $arguments) {
305
-        if(strtolower(substr($method, 0, 3)) === 'get') {
305
+        if (strtolower(substr($method, 0, 3)) === 'get') {
306 306
             $name = Str::snake(substr($method, 3));
307 307
             return $this->get($name);
308 308
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
309 309
             $name = Str::snake(substr($method, 3));
310 310
 
311
-            if(in_array($name, array_keys($this->attributes))) {
311
+            if (in_array($name, array_keys($this->attributes))) {
312 312
                 return $this->__set($name, array_pop($arguments));
313 313
             }
314 314
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
      * @return mixed|null
348 348
      */
349 349
     public function get($name) {
350
-        if(isset($this->attributes[$name])) {
350
+        if (isset($this->attributes[$name])) {
351 351
             return $this->attributes[$name];
352 352
         }
353 353
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      *
422 422
      * @throws InvalidMessageDateException
423 423
      */
424
-    public function parseRawHeader($raw_header){
424
+    public function parseRawHeader($raw_header) {
425 425
         $this->header = new Header($raw_header);
426 426
     }
427 427
 
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
     public function parseRawFlags($raw_flags) {
433 433
         $this->flags = FlagCollection::make([]);
434 434
 
435
-        foreach($raw_flags as $flag) {
436
-            if (strpos($flag, "\\") === 0){
435
+        foreach ($raw_flags as $flag) {
436
+            if (strpos($flag, "\\") === 0) {
437 437
                 $flag = substr($flag, 1);
438 438
             }
439 439
             $flag_key = strtolower($flag);
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
      * @throws MessageFlagException
507 507
      * @throws Exceptions\RuntimeException
508 508
      */
509
-    public function peek(){
509
+    public function peek() {
510 510
         if ($this->fetch_options == IMAP::FT_PEEK) {
511 511
             if ($this->getFlags()->get("seen") == null) {
512 512
                 $this->unsetFlag("Seen");
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
     private function fetchPart(Part $part) {
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);
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
         if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) {
593 593
             if ($oAttachment->getId() !== null) {
594 594
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
595
-            } else {
595
+            }else {
596 596
                 $this->attachments->push($oAttachment);
597 597
             }
598 598
         }
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 
727 727
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
728 728
             return @iconv($from, $to.'//IGNORE', $str);
729
-        } else {
729
+        }else {
730 730
             if (!$from) {
731 731
                 return mb_convert_encoding($str, $to);
732 732
             }
@@ -747,9 +747,9 @@  discard block
 block discarded – undo
747 747
                     return EncodingAliases::get($parameter->value);
748 748
                 }
749 749
             }
750
-        }elseif (property_exists($structure, 'charset')){
750
+        }elseif (property_exists($structure, 'charset')) {
751 751
             return EncodingAliases::get($structure->charset);
752
-        }elseif (is_string($structure) === true){
752
+        }elseif (is_string($structure) === true) {
753 753
             return mb_detect_encoding($structure);
754 754
         }
755 755
 
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
      * @throws Exceptions\FolderFetchingException
765 765
      * @throws Exceptions\RuntimeException
766 766
      */
767
-    public function getFolder(){
767
+    public function getFolder() {
768 768
         return $this->client->getFolder($this->folder_path);
769 769
     }
770 770
 
@@ -780,13 +780,13 @@  discard block
 block discarded – undo
780 780
      * @throws Exceptions\GetMessagesFailedException
781 781
      * @throws Exceptions\RuntimeException
782 782
      */
783
-    public function thread($sent_folder = null, &$thread = null, $folder = null){
783
+    public function thread($sent_folder = null, &$thread = null, $folder = null) {
784 784
         $thread = $thread ? $thread : MessageCollection::make([]);
785
-        $folder = $folder ? $folder :  $this->getFolder();
785
+        $folder = $folder ? $folder : $this->getFolder();
786 786
         $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
787 787
 
788 788
         /** @var Message $message */
789
-        foreach($thread as $message) {
789
+        foreach ($thread as $message) {
790 790
             if ($message->message_id == $this->message_id) {
791 791
                 return $thread;
792 792
             }
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
         $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder);
798 798
 
799 799
         if (is_array($this->in_reply_to)) {
800
-            foreach($this->in_reply_to as $in_reply_to) {
800
+            foreach ($this->in_reply_to as $in_reply_to) {
801 801
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder);
802 802
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder);
803 803
             }
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
      * @throws Exceptions\GetMessagesFailedException
819 819
      * @throws Exceptions\RuntimeException
820 820
      */
821
-    protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){
821
+    protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder) {
822 822
         $primary_folder->query()->inReplyTo($in_reply_to)
823 823
         ->setFetchBody($this->getFetchBodyOption())
824 824
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
      * @throws Exceptions\GetMessagesFailedException
840 840
      * @throws Exceptions\RuntimeException
841 841
      */
842
-    protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){
842
+    protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder) {
843 843
         $primary_folder->query()->messageId($message_id)
844 844
         ->setFetchBody($this->getFetchBodyOption())
845 845
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -932,14 +932,14 @@  discard block
 block discarded – undo
932 932
      * @throws MessageFlagException
933 933
      * @throws MessageHeaderFetchingException
934 934
      */
935
-    protected function fetchNewMail($folder, $next_uid, $event, $expunge){
936
-        if($expunge) $this->client->expunge();
935
+    protected function fetchNewMail($folder, $next_uid, $event, $expunge) {
936
+        if ($expunge) $this->client->expunge();
937 937
 
938 938
         $this->client->openFolder($folder->path);
939 939
 
940 940
         if ($this->sequence === IMAP::ST_UID) {
941 941
             $sequence_id = $next_uid;
942
-        }else{
942
+        }else {
943 943
             $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
944 944
         }
945 945
 
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
      */
963 963
     public function delete($expunge = true) {
964 964
         $status = $this->setFlag("Deleted");
965
-        if($expunge) $this->client->expunge();
965
+        if ($expunge) $this->client->expunge();
966 966
 
967 967
         $event = $this->getEvent("message", "deleted");
968 968
         $event::dispatch($this);
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
      */
983 983
     public function restore($expunge = true) {
984 984
         $status = $this->unsetFlag("Deleted");
985
-        if($expunge) $this->client->expunge();
985
+        if ($expunge) $this->client->expunge();
986 986
 
987 987
         $event = $this->getEvent("message", "restored");
988 988
         $event::dispatch($this);
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
      *
1088 1088
      * @return AttachmentCollection
1089 1089
      */
1090
-    public function attachments(){
1090
+    public function attachments() {
1091 1091
         return $this->getAttachments();
1092 1092
     }
1093 1093
 
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
      *
1186 1186
      * @return FlagCollection
1187 1187
      */
1188
-    public function flags(){
1188
+    public function flags() {
1189 1189
         return $this->getFlags();
1190 1190
     }
1191 1191
 
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
      *
1195 1195
      * @return Structure|null
1196 1196
      */
1197
-    public function getStructure(){
1197
+    public function getStructure() {
1198 1198
         return $this->structure;
1199 1199
     }
1200 1200
 
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
      *
1221 1221
      * @return array
1222 1222
      */
1223
-    public function getAttributes(){
1223
+    public function getAttributes() {
1224 1224
         return array_merge($this->attributes, $this->header->getAttributes());
1225 1225
     }
1226 1226
 
@@ -1230,8 +1230,8 @@  discard block
 block discarded – undo
1230 1230
      *
1231 1231
      * @return $this
1232 1232
      */
1233
-    public function setMask($mask){
1234
-        if(class_exists($mask)){
1233
+    public function setMask($mask) {
1234
+        if (class_exists($mask)) {
1235 1235
             $this->mask = $mask;
1236 1236
         }
1237 1237
 
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
      *
1244 1244
      * @return string
1245 1245
      */
1246
-    public function getMask(){
1246
+    public function getMask() {
1247 1247
         return $this->mask;
1248 1248
     }
1249 1249
 
@@ -1254,9 +1254,9 @@  discard block
 block discarded – undo
1254 1254
      * @return mixed
1255 1255
      * @throws MaskNotFoundException
1256 1256
      */
1257
-    public function mask($mask = null){
1257
+    public function mask($mask = null) {
1258 1258
         $mask = $mask !== null ? $mask : $this->mask;
1259
-        if(class_exists($mask)){
1259
+        if (class_exists($mask)) {
1260 1260
             return new $mask($this);
1261 1261
         }
1262 1262
 
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
      *
1270 1270
      * @return $this
1271 1271
      */
1272
-    public function setFolderPath($folder_path){
1272
+    public function setFolderPath($folder_path) {
1273 1273
         $this->folder_path = $folder_path;
1274 1274
 
1275 1275
         return $this;
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
      *
1282 1282
      * @return $this
1283 1283
      */
1284
-    public function setConfig($config){
1284
+    public function setConfig($config) {
1285 1285
         $this->config = $config;
1286 1286
 
1287 1287
         return $this;
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
      *
1294 1294
      * @return $this
1295 1295
      */
1296
-    public function setAvailableFlags($available_flags){
1296
+    public function setAvailableFlags($available_flags) {
1297 1297
         $this->available_flags = $available_flags;
1298 1298
 
1299 1299
         return $this;
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
      *
1306 1306
      * @return $this
1307 1307
      */
1308
-    public function setAttachments($attachments){
1308
+    public function setAttachments($attachments) {
1309 1309
         $this->attachments = $attachments;
1310 1310
 
1311 1311
         return $this;
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
      *
1318 1318
      * @return $this
1319 1319
      */
1320
-    public function setFlags($flags){
1320
+    public function setFlags($flags) {
1321 1321
         $this->flags = $flags;
1322 1322
 
1323 1323
         return $this;
@@ -1331,7 +1331,7 @@  discard block
 block discarded – undo
1331 1331
      * @throws Exceptions\RuntimeException
1332 1332
      * @throws Exceptions\ConnectionFailedException
1333 1333
      */
1334
-    public function setClient($client){
1334
+    public function setClient($client) {
1335 1335
         $this->client = $client;
1336 1336
         $this->client->openFolder($this->folder_path);
1337 1337
 
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
      * @throws Exceptions\RuntimeException
1347 1347
      * @return $this
1348 1348
      */
1349
-    public function setUid($uid){
1349
+    public function setUid($uid) {
1350 1350
         $this->uid = $uid;
1351 1351
         $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid);
1352 1352
         $this->msglist = null;
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
      * @throws Exceptions\RuntimeException
1364 1364
      * @return $this
1365 1365
      */
1366
-    public function setMsgn($msgn, $msglist = null){
1366
+    public function setMsgn($msgn, $msglist = null) {
1367 1367
         $this->msgn = $msgn;
1368 1368
         $this->msglist = $msglist;
1369 1369
         $this->uid = $this->client->getConnection()->getUid($this->msgn);
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
      *
1377 1377
      * @return int
1378 1378
      */
1379
-    public function getSequence(){
1379
+    public function getSequence() {
1380 1380
         return $this->sequence;
1381 1381
     }
1382 1382
 
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
      *
1386 1386
      * @return int
1387 1387
      */
1388
-    public function getSequenceId(){
1388
+    public function getSequenceId() {
1389 1389
         return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn;
1390 1390
     }
1391 1391
 
@@ -1397,11 +1397,11 @@  discard block
 block discarded – undo
1397 1397
      * @throws Exceptions\ConnectionFailedException
1398 1398
      * @throws Exceptions\RuntimeException
1399 1399
      */
1400
-    public function setSequenceId($uid, $msglist = null){
1400
+    public function setSequenceId($uid, $msglist = null) {
1401 1401
         if ($this->getSequence() === IMAP::ST_UID) {
1402 1402
             $this->setUid($uid);
1403 1403
             $this->setMsglist($msglist);
1404
-        }else{
1404
+        }else {
1405 1405
             $this->setMsgn($uid, $msglist);
1406 1406
         }
1407 1407
     }
Please login to merge, or discard this patch.