Passed
Pull Request — master (#113)
by
unknown
03:35
created
src/Address.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
      * @param object   $object
45 45
      */
46 46
     public function __construct($object) {
47
-        if (property_exists($object, "personal")){ $this->personal = $object->personal; }
48
-        if (property_exists($object, "mailbox")){ $this->mailbox = $object->mailbox; }
49
-        if (property_exists($object, "host")){ $this->host = $object->host; }
50
-        if (property_exists($object, "mail")){ $this->mail = $object->mail; }
51
-        if (property_exists($object, "full")){ $this->full = $object->full; }
47
+        if (property_exists($object, "personal")) { $this->personal = $object->personal; }
48
+        if (property_exists($object, "mailbox")) { $this->mailbox = $object->mailbox; }
49
+        if (property_exists($object, "host")) { $this->host = $object->host; }
50
+        if (property_exists($object, "mail")) { $this->mail = $object->mail; }
51
+        if (property_exists($object, "full")) { $this->full = $object->full; }
52 52
     }
53 53
 
54 54
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      *
67 67
      * @return array
68 68
      */
69
-    public function __serialize(){
69
+    public function __serialize() {
70 70
         return [
71 71
             "personal" => $this->personal,
72 72
             "mailbox" => $this->mailbox,
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @return array
83 83
      */
84
-    public function toArray(){
84
+    public function toArray() {
85 85
         return $this->__serialize();
86 86
     }
87 87
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      *
91 91
      * @return string
92 92
      */
93
-    public function toString(){
93
+    public function toString() {
94 94
         return $this->__toString();
95 95
     }
96 96
 }
97 97
\ No newline at end of file
Please login to merge, or discard this patch.
src/Connection/Protocols/ImapProtocol.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @throws ConnectionFailedException
85 85
      * @throws RuntimeException
86 86
      */
87
-    protected function enableTls(){
87
+    protected function enableTls() {
88 88
         $response = $this->requestAndResponse('STARTTLS');
89 89
         $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod());
90 90
         if (!$result) {
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         $stack = [];
147 147
 
148 148
         //  replace any trailing <NL> including spaces with a single space
149
-        $line = rtrim($line) . ' ';
149
+        $line = rtrim($line).' ';
150 150
         while (($pos = strpos($line, ' ')) !== false) {
151 151
             $token = substr($line, 0, $pos);
152 152
             if (!strlen($token)) {
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
                     if (strlen($token) > $chars) {
177 177
                         $line = substr($token, $chars);
178 178
                         $token = substr($token, 0, $chars);
179
-                    } else {
179
+                    }else {
180 180
                         $line .= $this->nextLine();
181 181
                     }
182 182
                     $tokens[] = $token;
183
-                    $line = trim($line) . ' ';
183
+                    $line = trim($line).' ';
184 184
                     continue;
185 185
                 }
186 186
             }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
         $line = $this->nextTaggedLine($tag); // get next tag
231 231
         if (!$dontParse) {
232 232
             $tokens = $this->decodeLine($line);
233
-        } else {
233
+        }else {
234 234
             $tokens = $line;
235 235
         }
236 236
         if ($this->debug) echo "<< ".$line."\n";
@@ -280,27 +280,27 @@  discard block
 block discarded – undo
280 280
     public function sendRequest($command, $tokens = [], &$tag = null) {
281 281
         if (!$tag) {
282 282
             $this->noun++;
283
-            $tag = 'TAG' . $this->noun;
283
+            $tag = 'TAG'.$this->noun;
284 284
         }
285 285
 
286
-        $line = $tag . ' ' . $command;
286
+        $line = $tag.' '.$command;
287 287
 
288 288
         foreach ($tokens as $token) {
289 289
             if (is_array($token)) {
290
-                if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) {
290
+                if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) {
291 291
                     throw new RuntimeException('failed to write - connection closed?');
292 292
                 }
293 293
                 if (!$this->assumedNextLine('+ ')) {
294 294
                     throw new RuntimeException('failed to send literal string');
295 295
                 }
296 296
                 $line = $token[1];
297
-            } else {
298
-                $line .= ' ' . $token;
297
+            }else {
298
+                $line .= ' '.$token;
299 299
             }
300 300
         }
301 301
         if ($this->debug) echo ">> ".$line."\n";
302 302
 
303
-        if (fwrite($this->stream, $line . "\r\n") === false) {
303
+        if (fwrite($this->stream, $line."\r\n") === false) {
304 304
             throw new RuntimeException('failed to write - connection closed?');
305 305
         }
306 306
     }
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
     public function escapeString($string) {
331 331
         if (func_num_args() < 2) {
332 332
             if (strpos($string, "\n") !== false) {
333
-                return ['{' . strlen($string) . '}', $string];
334
-            } else {
335
-                return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
333
+                return ['{'.strlen($string).'}', $string];
334
+            }else {
335
+                return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"';
336 336
             }
337 337
         }
338 338
         $result = [];
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             }
358 358
             $result[] = $this->escapeList($v);
359 359
         }
360
-        return '(' . implode(' ', $result) . ')';
360
+        return '('.implode(' ', $result).')';
361 361
     }
362 362
 
363 363
     /**
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
                     error_log("got an extra server challenge: $response");
398 398
                     // respond with an empty response.
399 399
                     $this->sendRequest('');
400
-                } else {
400
+                }else {
401 401
                     if (preg_match('/^NO /i', $response) ||
402 402
                         preg_match('/^BAD /i', $response)) {
403 403
                         error_log("got failure response: $response");
404 404
                         return false;
405
-                    } else if (preg_match("/^OK /i", $response)) {
405
+                    }else if (preg_match("/^OK /i", $response)) {
406 406
                         return true;
407 407
                     }
408 408
                 }
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
      *
436 436
      * @return bool
437 437
      */
438
-    public function connected(){
438
+    public function connected() {
439 439
         return (boolean) $this->stream;
440 440
     }
441 441
 
@@ -482,10 +482,10 @@  discard block
 block discarded – undo
482 482
                     $result[strtolower($tokens[1])] = $tokens[0];
483 483
                     break;
484 484
                 case '[UIDVALIDITY':
485
-                    $result['uidvalidity'] = (int)$tokens[2];
485
+                    $result['uidvalidity'] = (int) $tokens[2];
486 486
                     break;
487 487
                 case '[UIDNEXT':
488
-                    $result['uidnext'] = (int)$tokens[2];
488
+                    $result['uidnext'] = (int) $tokens[2];
489 489
                     break;
490 490
                 default:
491 491
                     // ignore
@@ -539,17 +539,17 @@  discard block
 block discarded – undo
539 539
         if (is_array($from)) {
540 540
             $set = implode(',', $from);
541 541
         } elseif ($to === null) {
542
-            $set = (int)$from;
542
+            $set = (int) $from;
543 543
         } elseif ($to === INF) {
544
-            $set = (int)$from . ':*';
545
-        } else {
546
-            $set = (int)$from . ':' . (int)$to;
544
+            $set = (int) $from.':*';
545
+        }else {
546
+            $set = (int) $from.':'.(int) $to;
547 547
         }
548 548
 
549
-        $items = (array)$items;
549
+        $items = (array) $items;
550 550
         $itemList = $this->escapeList($items);
551 551
 
552
-        $this->sendRequest(($uid ? 'UID ' : '') . 'FETCH', [$set, $itemList], $tag);
552
+        $this->sendRequest(($uid ? 'UID ' : '').'FETCH', [$set, $itemList], $tag);
553 553
 
554 554
         $result = [];
555 555
         $tokens = null; // define $tokens variable before first use
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
                 $count = count($tokens[2]);
565 565
                 if ($tokens[2][$count - 2] == 'UID') {
566 566
                     $uidKey = $count - 1;
567
-                } else if ($tokens[2][0] == 'UID') {
567
+                }else if ($tokens[2][0] == 'UID') {
568 568
                     $uidKey = 1;
569
-                } else {
569
+                }else {
570 570
                     $uidKey = array_search('UID', $tokens[2]) + 1;
571 571
                 }
572 572
             }
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
                     $data = $tokens[2][1];
583 583
                 } elseif ($uid && $tokens[2][2] == $items[0]) {
584 584
                     $data = $tokens[2][3];
585
-                } else {
585
+                }else {
586 586
                     // maybe the server send an other field we didn't wanted
587 587
                     $count = count($tokens[2]);
588 588
                     // we start with 2, because 0 was already checked
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
                         break;
595 595
                     }
596 596
                 }
597
-            } else {
597
+            }else {
598 598
                 $data = [];
599 599
                 while (key($tokens[2]) !== null) {
600 600
                     $data[current($tokens[2])] = next($tokens[2]);
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
             }
612 612
             if ($uid) {
613 613
                 $result[$tokens[2][$uidKey]] = $data;
614
-            }else{
614
+            }else {
615 615
                 $result[$tokens[0]] = $data;
616 616
             }
617 617
         }
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
      * @return array
646 646
      * @throws RuntimeException
647 647
      */
648
-    public function headers($uids, $rfc = "RFC822", $uid = false){
648
+    public function headers($uids, $rfc = "RFC822", $uid = false) {
649 649
         return $this->fetch(["$rfc.HEADER"], $uids, null, $uid);
650 650
     }
651 651
 
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
      * @return array
658 658
      * @throws RuntimeException
659 659
      */
660
-    public function flags($uids, $uid = false){
660
+    public function flags($uids, $uid = false) {
661 661
         return $this->fetch(["FLAGS"], $uids, null, $uid);
662 662
     }
663 663
 
@@ -742,23 +742,23 @@  discard block
 block discarded – undo
742 742
     public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) {
743 743
         $item = 'FLAGS';
744 744
         if ($mode == '+' || $mode == '-') {
745
-            $item = $mode . $item;
745
+            $item = $mode.$item;
746 746
         }
747 747
         if ($silent) {
748 748
             $item .= '.SILENT';
749 749
         }
750 750
 
751 751
         $flags = $this->escapeList($flags);
752
-        $set = (int)$from;
752
+        $set = (int) $from;
753 753
         if ($to !== null) {
754
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
754
+            $set .= ':'.($to == INF ? '*' : (int) $to);
755 755
         }
756 756
 
757 757
         $command = ($uid ? "UID " : "")."STORE";
758 758
         $result = $this->requestAndResponse($command, [$set, $item, $flags], $silent);
759 759
 
760 760
         if ($silent) {
761
-            return (bool)$result;
761
+            return (bool) $result;
762 762
         }
763 763
 
764 764
         $tokens = $result;
@@ -809,9 +809,9 @@  discard block
 block discarded – undo
809 809
      * @throws RuntimeException
810 810
      */
811 811
     public function copyMessage($folder, $from, $to = null, $uid = false) {
812
-        $set = (int)$from;
812
+        $set = (int) $from;
813 813
         if ($to !== null) {
814
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
814
+            $set .= ':'.($to == INF ? '*' : (int) $to);
815 815
         }
816 816
         $command = ($uid ? "UID " : "")."COPY";
817 817
 
@@ -830,9 +830,9 @@  discard block
 block discarded – undo
830 830
      * @throws RuntimeException
831 831
      */
832 832
     public function moveMessage($folder, $from, $to = null, $uid = false) {
833
-        $set = (int)$from;
833
+        $set = (int) $from;
834 834
         if ($to !== null) {
835
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
835
+            $set .= ':'.($to == INF ? '*' : (int) $to);
836 836
         }
837 837
         $command = ($uid ? "UID " : "")."MOVE";
838 838
 
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
         $ids = [];
1003 1003
         foreach ($uids as $msgn => $v) {
1004 1004
             $id = $uid ? $v : $msgn;
1005
-            if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){
1005
+            if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) {
1006 1006
                 $ids[] = $id;
1007 1007
             }
1008 1008
         }
@@ -1016,14 +1016,14 @@  discard block
 block discarded – undo
1016 1016
     /**
1017 1017
      * Enable the debug mode
1018 1018
      */
1019
-    public function enableDebug(){
1019
+    public function enableDebug() {
1020 1020
         $this->debug = true;
1021 1021
     }
1022 1022
 
1023 1023
     /**
1024 1024
      * Disable the debug mode
1025 1025
      */
1026
-    public function disableDebug(){
1026
+    public function disableDebug() {
1027 1027
         $this->debug = false;
1028 1028
     }
1029 1029
 }
1030 1030
\ No newline at end of file
Please login to merge, or discard this patch.
src/Part.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
      *
160 160
      * @throws InvalidMessageDateException
161 161
      */
162
-    protected function parse(){
162
+    protected function parse() {
163 163
         if ($this->header === null) {
164 164
             $body = $this->findHeaders();
165
-        }else{
165
+        }else {
166 166
             $body = $this->raw;
167 167
         }
168 168
 
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
         $this->name = $this->header->get("name");
175 175
         $this->filename = $this->header->get("filename");
176 176
 
177
-        if(!empty($this->header->get("id"))) {
177
+        if (!empty($this->header->get("id"))) {
178 178
             $this->id = $this->header->get("id");
179
-        } else if(!empty($this->header->get("x_attachment_id"))){
179
+        }else if (!empty($this->header->get("x_attachment_id"))) {
180 180
             $this->id = $this->header->get("x_attachment_id");
181
-        } else if(!empty($this->header->get("content_id"))){
181
+        }else if (!empty($this->header->get("content_id"))) {
182 182
             $this->id = strtr($this->header->get("content_id"), [
183 183
                 '<' => '',
184 184
                 '>' => ''
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         }
187 187
 
188 188
         $content_types = $this->header->get("content_type");
189
-        if(!empty($content_types)){
189
+        if (!empty($content_types)) {
190 190
             $this->subtype = $this->parseSubtype($content_types);
191 191
             $content_type = $content_types;
192 192
             if (is_array($content_types)) {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @return string
208 208
      * @throws InvalidMessageDateException
209 209
      */
210
-    private function findHeaders(){
210
+    private function findHeaders() {
211 211
         $body = $this->raw;
212 212
         while (($pos = strpos($body, "\r\n")) > 0) {
213 213
             $body = substr($body, $pos + 2);
@@ -226,16 +226,16 @@  discard block
 block discarded – undo
226 226
      *
227 227
      * @return string
228 228
      */
229
-    private function parseSubtype($content_type){
229
+    private function parseSubtype($content_type) {
230 230
         if (is_array($content_type)) {
231
-            foreach ($content_type as $part){
232
-                if ((strpos($part, "/")) !== false){
231
+            foreach ($content_type as $part) {
232
+                if ((strpos($part, "/")) !== false) {
233 233
                     return $this->parseSubtype($part);
234 234
                 }
235 235
             }
236 236
             return null;
237 237
         }
238
-        if (($pos = strpos($content_type, "/")) !== false){
238
+        if (($pos = strpos($content_type, "/")) !== false) {
239 239
             return substr($content_type, $pos + 1);
240 240
         }
241 241
         return null;
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
     /**
245 245
      * Try to parse the disposition if any is present
246 246
      */
247
-    private function parseDisposition(){
247
+    private function parseDisposition() {
248 248
         $content_disposition = $this->header->get("content_disposition");
249
-        if($content_disposition !== null) {
249
+        if ($content_disposition !== null) {
250 250
             $this->ifdisposition = true;
251 251
             $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition;
252 252
         }
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
     /**
256 256
      * Try to parse the description if any is present
257 257
      */
258
-    private function parseDescription(){
258
+    private function parseDescription() {
259 259
         $content_description = $this->header->get("content_description");
260
-        if($content_description !== null) {
260
+        if ($content_description !== null) {
261 261
             $this->ifdescription = true;
262 262
             $this->description = $content_description;
263 263
         }
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
     /**
267 267
      * Try to parse the encoding if any is present
268 268
      */
269
-    private function parseEncoding(){
269
+    private function parseEncoding() {
270 270
         $encoding = $this->header->get("content_transfer_encoding");
271
-        if($encoding !== null) {
271
+        if ($encoding !== null) {
272 272
             switch (strtolower($encoding)) {
273 273
                 case "quoted-printable":
274 274
                     $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      *
299 299
      * @return bool
300 300
      */
301
-    public function isAttachment(){
301
+    public function isAttachment() {
302 302
         $valid_disposition = in_array(strtolower($this->disposition), ClientManager::get('options.dispositions'));
303 303
 
304 304
         if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition))) && !$valid_disposition) {
Please login to merge, or discard this patch.
src/Header.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
      * @throws MethodNotFoundException
83 83
      */
84 84
     public function __call($method, $arguments) {
85
-        if(strtolower(substr($method, 0, 3)) === 'get') {
85
+        if (strtolower(substr($method, 0, 3)) === 'get') {
86 86
             $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3));
87 87
 
88
-            if(in_array($name, array_keys($this->attributes))) {
88
+            if (in_array($name, array_keys($this->attributes))) {
89 89
                 return $this->attributes[$name];
90 90
             }
91 91
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      * @return Attribute|mixed
112 112
      */
113 113
     public function get($name) {
114
-        if(isset($this->attributes[$name])) {
114
+        if (isset($this->attributes[$name])) {
115 115
             return $this->attributes[$name];
116 116
         }
117 117
 
@@ -127,23 +127,23 @@  discard block
 block discarded – undo
127 127
      * @return Attribute
128 128
      */
129 129
     public function set($name, $value, $strict = false) {
130
-        if(isset($this->attributes[$name]) && $strict === false) {
130
+        if (isset($this->attributes[$name]) && $strict === false) {
131 131
             if ($this->attributize) {
132 132
                 $this->attributes[$name]->add($value, true);
133
-            }else{
134
-                if(isset($this->attributes[$name])) {
133
+            }else {
134
+                if (isset($this->attributes[$name])) {
135 135
                     if (is_array($this->attributes[$name]) == false) {
136 136
                         $this->attributes[$name] = [$this->attributes[$name], $value];
137
-                    }else{
137
+                    }else {
138 138
                         $this->attributes[$name][] = $value;
139 139
                     }
140
-                }else{
140
+                }else {
141 141
                     $this->attributes[$name] = $value;
142 142
                 }
143 143
             }
144
-        }elseif($this->attributize == false){
144
+        }elseif ($this->attributize == false) {
145 145
             $this->attributes[$name] = $value;
146
-        }else{
146
+        }else {
147 147
             $this->attributes[$name] = new Attribute($name, $value);
148 148
         }
149 149
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     public function find($pattern) {
160 160
         if (preg_match_all($pattern, $this->raw, $matches)) {
161 161
             if (isset($matches[1])) {
162
-                if(count($matches[1]) > 0) {
162
+                if (count($matches[1]) > 0) {
163 163
                     return $matches[1][0];
164 164
                 }
165 165
             }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      *
173 173
      * @return string|null
174 174
      */
175
-    public function getBoundary(){
175
+    public function getBoundary() {
176 176
         $boundary = $this->find("/boundary\=(.*)/i");
177 177
 
178 178
         if ($boundary === null) {
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      *
198 198
      * @throws InvalidMessageDateException
199 199
      */
200
-    protected function parse(){
200
+    protected function parse() {
201 201
         $header = $this->rfc822_parse_headers($this->raw);
202 202
 
203 203
         $this->extractAddresses($header);
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         $this->parseDate($header);
216 216
         foreach ($header as $key => $value) {
217 217
             $key = trim(rtrim(strtolower($key)));
218
-            if(!isset($this->attributes[$key])){
218
+            if (!isset($this->attributes[$key])) {
219 219
                 $this->set($key, $value);
220 220
             }
221 221
         }
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
      *
232 232
      * @return object
233 233
      */
234
-    public function rfc822_parse_headers($raw_headers){
234
+    public function rfc822_parse_headers($raw_headers) {
235 235
         $headers = [];
236 236
         $imap_headers = [];
237 237
         if (extension_loaded('imap')) {
238 238
             $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw);
239
-            foreach($raw_imap_headers as $key => $values) {
239
+            foreach ($raw_imap_headers as $key => $values) {
240 240
                 $key = str_replace("-", "_", $key);
241 241
                 $imap_headers[$key] = $values;
242 242
             }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
         $lines = explode("\r\n", $raw_headers);
246 246
         $prev_header = null;
247
-        foreach($lines as $line) {
247
+        foreach ($lines as $line) {
248 248
             if (substr($line, 0, 1) === "\n") {
249 249
                 $line = substr($line, 1);
250 250
             }
@@ -264,19 +264,19 @@  discard block
 block discarded – undo
264 264
                     }
265 265
                     if (is_array($headers[$prev_header])) {
266 266
                         $headers[$prev_header][] = $line;
267
-                    }else{
267
+                    }else {
268 268
                         $headers[$prev_header] .= $line;
269 269
                     }
270 270
                 }
271
-            }else{
271
+            }else {
272 272
                 if (($pos = strpos($line, ":")) > 0) {
273 273
                     $key = trim(rtrim(strtolower(substr($line, 0, $pos))));
274 274
                     $key = str_replace("-", "_", $key);
275 275
 
276 276
                     $value = trim(rtrim(substr($line, $pos + 1)));
277 277
                     if (isset($headers[$key])) {
278
-                        $headers[$key][]  = $value;
279
-                    }else{
278
+                        $headers[$key][] = $value;
279
+                    }else {
280 280
                         $headers[$key] = [$value];
281 281
                     }
282 282
                     $prev_header = $key;
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
             }
285 285
         }
286 286
 
287
-        foreach($headers as $key => $values) {
287
+        foreach ($headers as $key => $values) {
288 288
             if (isset($imap_headers[$key])) continue;
289 289
             $value = null;
290
-            switch($key){
290
+            switch ($key) {
291 291
                 case 'from':
292 292
                 case 'to':
293 293
                 case 'cc':
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                     break;
303 303
                 default:
304 304
                     if (is_array($values)) {
305
-                        foreach($values as $k => $v) {
305
+                        foreach ($values as $k => $v) {
306 306
                             if ($v == "") {
307 307
                                 unset($values[$k]);
308 308
                             }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
                             $value = implode(" ", $values);
315 315
                         } elseif ($available_values > 2) {
316 316
                             $value = array_values($values);
317
-                        } else {
317
+                        }else {
318 318
                             $value = "";
319 319
                         }
320 320
                     }
@@ -334,12 +334,12 @@  discard block
 block discarded – undo
334 334
      * @return array The decoded elements are returned in an array of objects, where each
335 335
      * object has two properties, charset and text.
336 336
      */
337
-    public function mime_header_decode($text){
337
+    public function mime_header_decode($text) {
338 338
         if (extension_loaded('imap')) {
339 339
             return \imap_mime_header_decode($text);
340 340
         }
341 341
         $charset = $this->getEncoding($text);
342
-        return [(object)[
342
+        return [(object) [
343 343
             "charset" => $charset,
344 344
             "text" => $this->convertEncoding($text, $charset)
345 345
         ]];
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
         try {
394 394
             if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
395 395
                 return iconv($from, $to, $str);
396
-            } else {
396
+            }else {
397 397
                 if (!$from) {
398 398
                     return mb_convert_encoding($str, $to);
399 399
                 }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
             if (strstr($from, '-')) {
404 404
                 $from = str_replace('-', '', $from);
405 405
                 return $this->convertEncoding($str, $from, $to);
406
-            } else {
406
+            }else {
407 407
                 return $str;
408 408
             }
409 409
         }
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
             }
425 425
         }elseif (property_exists($structure, 'charset')) {
426 426
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
427
-        }elseif (is_string($structure) === true){
427
+        }elseif (is_string($structure) === true) {
428 428
             return mb_detect_encoding($structure);
429 429
         }
430 430
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
         if ($value !== null) {
458 458
             $is_utf8_base = $this->is_uft8($value);
459 459
 
460
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
460
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
461 461
                 $value = \imap_utf8($value);
462 462
                 $is_utf8_base = $this->is_uft8($value);
463 463
                 if ($is_utf8_base) {
@@ -466,14 +466,14 @@  discard block
 block discarded – undo
466 466
                 if ($this->notDecoded($original_value, $value)) {
467 467
                     $decoded_value = $this->mime_header_decode($value);
468 468
                     if (count($decoded_value) > 0) {
469
-                        if(property_exists($decoded_value[0], "text")) {
469
+                        if (property_exists($decoded_value[0], "text")) {
470 470
                             $value = $decoded_value[0]->text;
471 471
                         }
472 472
                     }
473 473
                 }
474
-            }elseif($decoder === 'iconv' && $is_utf8_base) {
474
+            }elseif ($decoder === 'iconv' && $is_utf8_base) {
475 475
                 $value = iconv_mime_decode($value);
476
-            }elseif($is_utf8_base){
476
+            }elseif ($is_utf8_base) {
477 477
                 $value = mb_decode_mimeheader($value);
478 478
             }
479 479
 
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
      * @return array
497 497
      */
498 498
     private function decodeArray($values) {
499
-        foreach($values as $key => $value) {
499
+        foreach ($values as $key => $value) {
500 500
             $values[$key] = $this->decode($value);
501 501
         }
502 502
         return $values;
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
      * Try to extract the priority from a given raw header string
507 507
      */
508 508
     private function findPriority() {
509
-        if(($priority = $this->get("x_priority")) === null) return;
510
-        switch((int)"$priority"){
509
+        if (($priority = $this->get("x_priority")) === null) return;
510
+        switch ((int) "$priority") {
511 511
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
512 512
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
513 513
                 break;
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
      */
540 540
     private function decodeAddresses($values) {
541 541
         $addresses = [];
542
-        foreach($values as $address) {
542
+        foreach ($values as $address) {
543 543
             $address = trim(rtrim($address));
544 544
             if (strpos($address, ",") == strlen($address) - 1) {
545 545
                 $address = substr($address, 0, -1);
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
                 '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/',
549 549
                 $address,
550 550
                 $matches
551
-            )){
551
+            )) {
552 552
                 $name = trim(rtrim($matches["name"]));
553 553
                 $email = trim(rtrim($matches["email"]));
554 554
                 list($mailbox, $host) = array_pad(explode("@", $email), 2, null);
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
      * @param object $header
568 568
      */
569 569
     private function extractAddresses($header) {
570
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){
570
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) {
571 571
             if (property_exists($header, $key)) {
572 572
                 $this->set($key, $this->parseAddresses($header->$key));
573 573
             }
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
             }
599 599
             if (!property_exists($address, 'personal')) {
600 600
                 $address->personal = false;
601
-            } else {
601
+            }else {
602 602
                 $personalParts = $this->mime_header_decode($address->personal);
603 603
 
604
-                if(is_array($personalParts)) {
604
+                if (is_array($personalParts)) {
605 605
                     $address->personal = '';
606 606
                     foreach ($personalParts as $p) {
607 607
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -625,23 +625,23 @@  discard block
 block discarded – undo
625 625
     /**
626 626
      * Search and extract potential header extensions
627 627
      */
628
-    private function extractHeaderExtensions(){
628
+    private function extractHeaderExtensions() {
629 629
         foreach ($this->attributes as $key => $value) {
630 630
             if (is_array($value)) {
631 631
                 $value = implode(", ", $value);
632
-            }else{
633
-                $value = (string)$value;
632
+            }else {
633
+                $value = (string) $value;
634 634
             }
635 635
             // Only parse strings and don't parse any attributes like the user-agent
636 636
             if (in_array($key, ["user_agent"]) === false) {
637
-                if (($pos = strpos($value, ";")) !== false){
637
+                if (($pos = strpos($value, ";")) !== false) {
638 638
                     $original = substr($value, 0, $pos);
639 639
                     $this->set($key, trim(rtrim($original)), true);
640 640
 
641 641
                     // Get all potential extensions
642 642
                     $extensions = explode(";", substr($value, $pos + 1));
643
-                    foreach($extensions as $extension) {
644
-                        if (($pos = strpos($extension, "=")) !== false){
643
+                    foreach ($extensions as $extension) {
644
+                        if (($pos = strpos($extension, "=")) !== false) {
645 645
                             $key = substr($extension, 0, $pos);
646 646
                             $key = trim(rtrim(strtolower($key)));
647 647
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
             $parsed_date = null;
685 685
             $date = $header->date;
686 686
 
687
-            if(preg_match('/\+0580/', $date)) {
687
+            if (preg_match('/\+0580/', $date)) {
688 688
                 $date = str_replace('+0580', '+0530', $date);
689 689
             }
690 690
 
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
                         $date = trim(array_pop($array));
708 708
                         break;
709 709
                 }
710
-                try{
710
+                try {
711 711
                     $parsed_date = Carbon::parse($date);
712 712
                 } catch (\Exception $_e) {
713 713
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e);
Please login to merge, or discard this patch.
src/Structure.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @throws MessageContentFetchingException
78 78
      * @throws InvalidMessageDateException
79 79
      */
80
-    protected function parse(){
80
+    protected function parse() {
81 81
         $this->findContentType();
82 82
         $this->parts = $this->find_parts();
83 83
     }
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
     /**
86 86
      * Determine the message content type
87 87
      */
88
-    public function findContentType(){
88
+    public function findContentType() {
89 89
         $content_type = $this->header->get("content_type");
90 90
         $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type;
91
-        if(stripos($content_type, 'multipart') === 0) {
91
+        if (stripos($content_type, 'multipart') === 0) {
92 92
             $this->type = IMAP::MESSAGE_TYPE_MULTIPART;
93
-        }else{
93
+        }else {
94 94
             $this->type = IMAP::MESSAGE_TYPE_TEXT;
95 95
         }
96 96
     }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      * @return Part[]
104 104
      * @throws InvalidMessageDateException
105 105
      */
106
-    private function parsePart($context, $part_number = 0){
106
+    private function parsePart($context, $part_number = 0) {
107 107
         $body = $context;
108 108
         while (($pos = strpos($body, "\r\n")) > 0) {
109 109
             $body = substr($body, $pos + 2);
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
      * @return array
127 127
      * @throws InvalidMessageDateException
128 128
      */
129
-    private function detectParts($boundary, $context, $part_number = 0){
130
-        $base_parts = explode( $boundary, $context);
129
+    private function detectParts($boundary, $context, $part_number = 0) {
130
+        $base_parts = explode($boundary, $context);
131 131
         $final_parts = [];
132
-        foreach($base_parts as $ctx) {
132
+        foreach ($base_parts as $ctx) {
133 133
             $ctx = substr($ctx, 2);
134 134
             if ($ctx !== "--" && $ctx != "") {
135 135
                 $parts = $this->parsePart($ctx, $part_number);
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
      * @throws MessageContentFetchingException
151 151
      * @throws InvalidMessageDateException
152 152
      */
153
-    public function find_parts(){
154
-        if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
155
-            if (($boundary = $this->header->getBoundary()) === null)  {
153
+    public function find_parts() {
154
+        if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
155
+            if (($boundary = $this->header->getBoundary()) === null) {
156 156
                 throw new MessageContentFetchingException("no content found", 0);
157 157
             }
158 158
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      * @return string|null
169 169
      * @Depricated since version 2.4.4
170 170
      */
171
-    public function getBoundary(){
171
+    public function getBoundary() {
172 172
         return $this->header->getBoundary();
173 173
     }
174 174
 }
Please login to merge, or discard this patch.
src/Query/WhereQuery.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
         }
86 86
 
87 87
         if (strpos(strtolower($name), "where") === false) {
88
-            $method = 'where' . ucfirst($name);
89
-        } else {
88
+            $method = 'where'.ucfirst($name);
89
+        }else {
90 90
             $method = lcfirst($name);
91 91
         }
92 92
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
             return call_user_func_array([$that, $method], $arguments);
95 95
         }
96 96
 
97
-        throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported');
97
+        throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported');
98 98
     }
99 99
 
100 100
     /**
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
                 }
132 132
                 return $this->where($key, $value);
133 133
             }
134
-        } else {
134
+        }else {
135 135
             $criteria = $this->validate_criteria($criteria);
136 136
             $value = $this->parse_value($value);
137 137
 
138 138
             if ($value === null || $value === '') {
139 139
                 $this->query->push([$criteria]);
140
-            } else {
140
+            }else {
141 141
                 $this->query->push([$criteria, $value]);
142 142
             }
143 143
         }
Please login to merge, or discard this patch.
src/Support/Masks/MessageMask.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @return null
32 32
      */
33
-    public function getHtmlBody(){
33
+    public function getHtmlBody() {
34 34
         $bodies = $this->parent->getBodies();
35 35
         if (!isset($bodies['html'])) {
36 36
             return null;
37 37
         }
38 38
 
39
-        if(is_object($bodies['html']) && property_exists($bodies['html'], 'content')) {
39
+        if (is_object($bodies['html']) && property_exists($bodies['html'], 'content')) {
40 40
             return $bodies['html']->content;
41 41
         }
42 42
         return $bodies['html'];
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function getCustomHTMLBody($callback = false) {
52 52
         $body = $this->getHtmlBody();
53
-        if($body === null) return null;
53
+        if ($body === null) return null;
54 54
 
55 55
         if ($callback !== false) {
56 56
             $aAttachment = $this->parent->getAttachments();
57 57
             $aAttachment->each(function($oAttachment) use(&$body, $callback) {
58 58
                 /** @var Attachment $oAttachment */
59
-                if(is_callable($callback)) {
59
+                if (is_callable($callback)) {
60 60
                     $body = $callback($body, $oAttachment);
61
-                }elseif(is_string($callback)) {
61
+                }elseif (is_string($callback)) {
62 62
                     call_user_func($callback, [$body, $oAttachment]);
63 63
                 }
64 64
             });
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @return string|null
75 75
      */
76 76
     public function getHTMLBodyWithEmbeddedBase64Images() {
77
-        return $this->getCustomHTMLBody(function($body, $oAttachment){
77
+        return $this->getCustomHTMLBody(function($body, $oAttachment) {
78 78
             /** @var Attachment $oAttachment */
79 79
             if ($oAttachment->id) {
80 80
                 $body = str_replace('cid:'.$oAttachment->id, 'data:'.$oAttachment->getContentType().';base64, '.base64_encode($oAttachment->getContent()), $body);
Please login to merge, or discard this patch.
src/Query/Query.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
         if (ClientManager::get('options.fetch_order') === 'desc') {
97 97
             $this->fetch_order = 'desc';
98
-        } else {
98
+        }else {
99 99
             $this->fetch_order = 'asc';
100 100
         }
101 101
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                 break;
127 127
         }
128 128
 
129
-        return (string)$value;
129
+        return (string) $value;
130 130
     }
131 131
 
132 132
     /**
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
         $this->query->each(function($statement) use (&$query) {
159 159
             if (count($statement) == 1) {
160 160
                 $query .= $statement[0];
161
-            } else {
161
+            }else {
162 162
                 if ($statement[1] === null) {
163 163
                     $query .= $statement[0];
164
-                } else {
165
-                    $query .= $statement[0] . ' "' . $statement[1] . '"';
164
+                }else {
165
+                    $query .= $statement[0].' "'.$statement[1].'"';
166 166
                 }
167 167
             }
168 168
             $query .= ' ';
@@ -247,18 +247,18 @@  discard block
 block discarded – undo
247 247
      * @throws GetMessagesFailedException
248 248
      * @throws ReflectionException
249 249
      */
250
-    protected function make($uid, $msglist, $header, $content, $flags){
250
+    protected function make($uid, $msglist, $header, $content, $flags) {
251 251
         try {
252 252
             return Message::make($uid, $msglist, $this->getClient(), $header, $content, $flags, $this->getFetchOptions(), $this->sequence);
253
-        }catch (MessageNotFoundException $e) {
253
+        } catch (MessageNotFoundException $e) {
254 254
             $this->setError($uid, $e);
255
-        }catch (RuntimeException $e) {
255
+        } catch (RuntimeException $e) {
256 256
             $this->setError($uid, $e);
257
-        }catch (MessageFlagException $e) {
257
+        } catch (MessageFlagException $e) {
258 258
             $this->setError($uid, $e);
259
-        }catch (InvalidMessageDateException $e) {
259
+        } catch (InvalidMessageDateException $e) {
260 260
             $this->setError($uid, $e);
261
-        }catch (MessageContentFetchingException $e) {
261
+        } catch (MessageContentFetchingException $e) {
262 262
             $this->setError($uid, $e);
263 263
         }
264 264
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
      *
276 276
      * @return string
277 277
      */
278
-    protected function getMessageKey($message_key, $msglist, $message){
278
+    protected function getMessageKey($message_key, $msglist, $message) {
279 279
         switch ($message_key) {
280 280
             case 'number':
281 281
                 $key = $message->getMessageNo();
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                 $key = $message->getMessageId();
291 291
                 break;
292 292
         }
293
-        return (string)$key;
293
+        return (string) $key;
294 294
     }
295 295
 
296 296
     /**
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
      *
783 783
      * @return boolean
784 784
      */
785
-    public function hasErrors($uid = null){
785
+    public function hasErrors($uid = null) {
786 786
         if ($uid !== null) {
787 787
             return $this->hasError($uid);
788 788
         }
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
      *
796 796
      * @return boolean
797 797
      */
798
-    public function hasError($uid){
798
+    public function hasError($uid) {
799 799
         return isset($this->errors[$uid]);
800 800
     }
801 801
 
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
      *
805 805
      * @return array
806 806
      */
807
-    public function errors(){
807
+    public function errors() {
808 808
         return $this->getErrors();
809 809
     }
810 810
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
      *
814 814
      * @return array
815 815
      */
816
-    public function getErrors(){
816
+    public function getErrors() {
817 817
         return $this->errors;
818 818
     }
819 819
 
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
      *
824 824
      * @return Exception|null
825 825
      */
826
-    public function error($uid){
826
+    public function error($uid) {
827 827
         return $this->getError($uid);
828 828
     }
829 829
 
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
      *
834 834
      * @return Exception|null
835 835
      */
836
-    public function getError($uid){
836
+    public function getError($uid) {
837 837
         if ($this->hasError($uid)) {
838 838
             return $this->errors[$uid];
839 839
         }
Please login to merge, or discard this patch.
src/Message.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         $this->boot();
193 193
 
194 194
         $default_mask = $client->getDefaultMessageMask();
195
-        if($default_mask != null) {
195
+        if ($default_mask != null) {
196 196
             $this->mask = $default_mask;
197 197
         }
198 198
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
      * @throws Exceptions\RuntimeException
247 247
      * @throws Exceptions\MessageNotFoundException
248 248
      */
249
-    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){
249
+    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) {
250 250
         $reflection = new ReflectionClass(self::class);
251 251
         /** @var self $instance */
252 252
         $instance = $reflection->newInstanceWithoutConstructor();
253 253
         $instance->boot();
254 254
 
255 255
         $default_mask = $client->getDefaultMessageMask();
256
-        if($default_mask != null) {
256
+        if ($default_mask != null) {
257 257
             $instance->setMask($default_mask);
258 258
         }
259 259
         $instance->setEvents([
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
     /**
279 279
      * Boot a new instance
280 280
      */
281
-    public function boot(){
281
+    public function boot() {
282 282
         $this->attributes = [];
283 283
 
284 284
         $this->config = ClientManager::get('options');
@@ -297,13 +297,13 @@  discard block
 block discarded – undo
297 297
      * @throws MethodNotFoundException
298 298
      */
299 299
     public function __call($method, $arguments) {
300
-        if(strtolower(substr($method, 0, 3)) === 'get') {
300
+        if (strtolower(substr($method, 0, 3)) === 'get') {
301 301
             $name = Str::snake(substr($method, 3));
302 302
             return $this->get($name);
303 303
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
304 304
             $name = Str::snake(substr($method, 3));
305 305
 
306
-            if(in_array($name, array_keys($this->attributes))) {
306
+            if (in_array($name, array_keys($this->attributes))) {
307 307
                 return $this->__set($name, array_pop($arguments));
308 308
             }
309 309
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
      * @return Attribute|mixed|null
343 343
      */
344 344
     public function get($name) {
345
-        if(isset($this->attributes[$name])) {
345
+        if (isset($this->attributes[$name])) {
346 346
             return $this->attributes[$name];
347 347
         }
348 348
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
      *
417 417
      * @throws InvalidMessageDateException
418 418
      */
419
-    public function parseRawHeader($raw_header){
419
+    public function parseRawHeader($raw_header) {
420 420
         $this->header = new Header($raw_header);
421 421
     }
422 422
 
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
     public function parseRawFlags($raw_flags) {
428 428
         $this->flags = FlagCollection::make([]);
429 429
 
430
-        foreach($raw_flags as $flag) {
431
-            if (strpos($flag, "\\") === 0){
430
+        foreach ($raw_flags as $flag) {
431
+            if (strpos($flag, "\\") === 0) {
432 432
                 $flag = substr($flag, 1);
433 433
             }
434 434
             $flag_key = strtolower($flag);
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
      * @throws MessageFlagException
502 502
      * @throws Exceptions\RuntimeException
503 503
      */
504
-    public function peek(){
504
+    public function peek() {
505 505
         if ($this->fetch_options == IMAP::FT_PEEK) {
506 506
             if ($this->getFlags()->get("seen") == null) {
507 507
                 $this->unsetFlag("Seen");
@@ -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);
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 
576 576
             if (isset($this->bodies[$subtype])) {
577 577
                 $this->bodies[$subtype] .= "\n".$content;
578
-            }else{
578
+            }else {
579 579
                 $this->bodies[$subtype] = $content;
580 580
             }
581 581
         }
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
         if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) {
592 592
             if ($oAttachment->getId() !== null) {
593 593
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
594
-            } else {
594
+            }else {
595 595
                 $this->attachments->push($oAttachment);
596 596
             }
597 597
         }
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 
726 726
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
727 727
             return @iconv($from, $to.'//IGNORE', $str);
728
-        } else {
728
+        }else {
729 729
             if (!$from) {
730 730
                 return mb_convert_encoding($str, $to);
731 731
             }
@@ -746,9 +746,9 @@  discard block
 block discarded – undo
746 746
                     return EncodingAliases::get($parameter->value);
747 747
                 }
748 748
             }
749
-        }elseif (property_exists($structure, 'charset')){
749
+        }elseif (property_exists($structure, 'charset')) {
750 750
             return EncodingAliases::get($structure->charset);
751
-        }elseif (is_string($structure) === true){
751
+        }elseif (is_string($structure) === true) {
752 752
             return mb_detect_encoding($structure);
753 753
         }
754 754
 
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
      * @throws Exceptions\FolderFetchingException
764 764
      * @throws Exceptions\RuntimeException
765 765
      */
766
-    public function getFolder(){
766
+    public function getFolder() {
767 767
         return $this->client->getFolderByPath($this->folder_path);
768 768
     }
769 769
 
@@ -779,13 +779,13 @@  discard block
 block discarded – undo
779 779
      * @throws Exceptions\GetMessagesFailedException
780 780
      * @throws Exceptions\RuntimeException
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->getFolderByPath(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->first() == $this->message_id->first()) {
790 790
                 return $thread;
791 791
             }
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
         $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder);
797 797
 
798 798
         if (is_array($this->in_reply_to)) {
799
-            foreach($this->in_reply_to as $in_reply_to) {
799
+            foreach ($this->in_reply_to as $in_reply_to) {
800 800
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder);
801 801
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder);
802 802
             }
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
      * @throws Exceptions\GetMessagesFailedException
818 818
      * @throws Exceptions\RuntimeException
819 819
      */
820
-    protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){
820
+    protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder) {
821 821
         $primary_folder->query()->inReplyTo($in_reply_to)
822 822
         ->setFetchBody($this->getFetchBodyOption())
823 823
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
      * @throws Exceptions\GetMessagesFailedException
839 839
      * @throws Exceptions\RuntimeException
840 840
      */
841
-    protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){
841
+    protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder) {
842 842
         $primary_folder->query()->messageId($message_id)
843 843
         ->setFetchBody($this->getFetchBodyOption())
844 844
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -934,14 +934,14 @@  discard block
 block discarded – undo
934 934
      * @throws MessageFlagException
935 935
      * @throws MessageHeaderFetchingException
936 936
      */
937
-    protected function fetchNewMail($folder, $next_uid, $event, $expunge){
938
-        if($expunge) $this->client->expunge();
937
+    protected function fetchNewMail($folder, $next_uid, $event, $expunge) {
938
+        if ($expunge) $this->client->expunge();
939 939
 
940 940
         $this->client->openFolder($folder->path);
941 941
 
942 942
         if ($this->sequence === IMAP::ST_UID) {
943 943
             $sequence_id = $next_uid;
944
-        }else{
944
+        }else {
945 945
             $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
946 946
         }
947 947
 
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
      */
965 965
     public function delete($expunge = true) {
966 966
         $status = $this->setFlag("Deleted");
967
-        if($expunge) $this->client->expunge();
967
+        if ($expunge) $this->client->expunge();
968 968
 
969 969
         $event = $this->getEvent("message", "deleted");
970 970
         $event::dispatch($this);
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
      */
985 985
     public function restore($expunge = true) {
986 986
         $status = $this->unsetFlag("Deleted");
987
-        if($expunge) $this->client->expunge();
987
+        if ($expunge) $this->client->expunge();
988 988
 
989 989
         $event = $this->getEvent("message", "restored");
990 990
         $event::dispatch($this);
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
      *
1090 1090
      * @return AttachmentCollection
1091 1091
      */
1092
-    public function attachments(){
1092
+    public function attachments() {
1093 1093
         return $this->getAttachments();
1094 1094
     }
1095 1095
 
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
      *
1188 1188
      * @return FlagCollection
1189 1189
      */
1190
-    public function flags(){
1190
+    public function flags() {
1191 1191
         return $this->getFlags();
1192 1192
     }
1193 1193
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
      *
1197 1197
      * @return Structure|null
1198 1198
      */
1199
-    public function getStructure(){
1199
+    public function getStructure() {
1200 1200
         return $this->structure;
1201 1201
     }
1202 1202
 
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
      *
1223 1223
      * @return array
1224 1224
      */
1225
-    public function getAttributes(){
1225
+    public function getAttributes() {
1226 1226
         return array_merge($this->attributes, $this->header->getAttributes());
1227 1227
     }
1228 1228
 
@@ -1232,8 +1232,8 @@  discard block
 block discarded – undo
1232 1232
      *
1233 1233
      * @return $this
1234 1234
      */
1235
-    public function setMask($mask){
1236
-        if(class_exists($mask)){
1235
+    public function setMask($mask) {
1236
+        if (class_exists($mask)) {
1237 1237
             $this->mask = $mask;
1238 1238
         }
1239 1239
 
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
      *
1246 1246
      * @return string
1247 1247
      */
1248
-    public function getMask(){
1248
+    public function getMask() {
1249 1249
         return $this->mask;
1250 1250
     }
1251 1251
 
@@ -1256,9 +1256,9 @@  discard block
 block discarded – undo
1256 1256
      * @return mixed
1257 1257
      * @throws MaskNotFoundException
1258 1258
      */
1259
-    public function mask($mask = null){
1259
+    public function mask($mask = null) {
1260 1260
         $mask = $mask !== null ? $mask : $this->mask;
1261
-        if(class_exists($mask)){
1261
+        if (class_exists($mask)) {
1262 1262
             return new $mask($this);
1263 1263
         }
1264 1264
 
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
      *
1272 1272
      * @return $this
1273 1273
      */
1274
-    public function setFolderPath($folder_path){
1274
+    public function setFolderPath($folder_path) {
1275 1275
         $this->folder_path = $folder_path;
1276 1276
 
1277 1277
         return $this;
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
      *
1284 1284
      * @return $this
1285 1285
      */
1286
-    public function setConfig($config){
1286
+    public function setConfig($config) {
1287 1287
         $this->config = $config;
1288 1288
 
1289 1289
         return $this;
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
      *
1296 1296
      * @return $this
1297 1297
      */
1298
-    public function setAvailableFlags($available_flags){
1298
+    public function setAvailableFlags($available_flags) {
1299 1299
         $this->available_flags = $available_flags;
1300 1300
 
1301 1301
         return $this;
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
      *
1308 1308
      * @return $this
1309 1309
      */
1310
-    public function setAttachments($attachments){
1310
+    public function setAttachments($attachments) {
1311 1311
         $this->attachments = $attachments;
1312 1312
 
1313 1313
         return $this;
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
      *
1320 1320
      * @return $this
1321 1321
      */
1322
-    public function setFlags($flags){
1322
+    public function setFlags($flags) {
1323 1323
         $this->flags = $flags;
1324 1324
 
1325 1325
         return $this;
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
      * @throws Exceptions\RuntimeException
1334 1334
      * @throws Exceptions\ConnectionFailedException
1335 1335
      */
1336
-    public function setClient($client){
1336
+    public function setClient($client) {
1337 1337
         $this->client = $client;
1338 1338
         $this->client->openFolder($this->folder_path);
1339 1339
 
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
      * @throws Exceptions\MessageNotFoundException
1349 1349
      * @throws Exceptions\ConnectionFailedException
1350 1350
      */
1351
-    public function setUid($uid){
1351
+    public function setUid($uid) {
1352 1352
         $this->uid = $uid;
1353 1353
         $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid);
1354 1354
         $this->msglist = null;
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
      * @throws Exceptions\MessageNotFoundException
1366 1366
      * @throws Exceptions\ConnectionFailedException
1367 1367
      */
1368
-    public function setMsgn($msgn, $msglist = null){
1368
+    public function setMsgn($msgn, $msglist = null) {
1369 1369
         $this->msgn = $msgn;
1370 1370
         $this->msglist = $msglist;
1371 1371
         $this->uid = $this->client->getConnection()->getUid($this->msgn);
@@ -1378,7 +1378,7 @@  discard block
 block discarded – undo
1378 1378
      *
1379 1379
      * @return int
1380 1380
      */
1381
-    public function getSequence(){
1381
+    public function getSequence() {
1382 1382
         return $this->sequence;
1383 1383
     }
1384 1384
 
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
      *
1388 1388
      * @return int
1389 1389
      */
1390
-    public function getSequenceId(){
1390
+    public function getSequenceId() {
1391 1391
         return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn;
1392 1392
     }
1393 1393
 
@@ -1399,11 +1399,11 @@  discard block
 block discarded – undo
1399 1399
      * @throws Exceptions\ConnectionFailedException
1400 1400
      * @throws Exceptions\MessageNotFoundException
1401 1401
      */
1402
-    public function setSequenceId($uid, $msglist = null){
1402
+    public function setSequenceId($uid, $msglist = null) {
1403 1403
         if ($this->getSequence() === IMAP::ST_UID) {
1404 1404
             $this->setUid($uid);
1405 1405
             $this->setMsglist($msglist);
1406
-        }else{
1406
+        }else {
1407 1407
             $this->setMsgn($uid, $msglist);
1408 1408
         }
1409 1409
     }
Please login to merge, or discard this patch.