Passed
Push — master ( 17f7bb...ab922f )
by Malte
02:36
created
src/Query/WhereQuery.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
 
77 77
         $name = Str::camel($name);
78 78
 
79
-        if(strtolower(substr($name, 0, 3)) === 'not') {
79
+        if (strtolower(substr($name, 0, 3)) === 'not') {
80 80
             $that = $that->whereNot();
81 81
             $name = substr($name, 3);
82 82
         }
83 83
 
84
-        if (strpos(strtolower($name), "where") === false){
84
+        if (strpos(strtolower($name), "where") === false) {
85 85
             $method = 'where'.ucfirst($name);
86
-        }else{
86
+        }else {
87 87
             $method = lcfirst($name);
88 88
         }
89 89
 
90
-        if(method_exists($this, $method) === true){
90
+        if (method_exists($this, $method) === true) {
91 91
             return call_user_func_array([$that, $method], $arguments);
92 92
         }
93 93
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         if (substr($criteria, 0, 7) === "CUSTOM ") {
107 107
             return substr($criteria, 7);
108 108
         }
109
-        if(in_array($criteria, $this->available_criteria) === false) {
109
+        if (in_array($criteria, $this->available_criteria) === false) {
110 110
             throw new InvalidWhereQueryCriteriaException();
111 111
         }
112 112
 
@@ -121,20 +121,20 @@  discard block
 block discarded – undo
121 121
      * @throws InvalidWhereQueryCriteriaException
122 122
      */
123 123
     public function where($criteria, $value = null) {
124
-        if(is_array($criteria)){
125
-            foreach($criteria as $key => $value){
126
-                if(is_numeric($key)){
124
+        if (is_array($criteria)) {
125
+            foreach ($criteria as $key => $value) {
126
+                if (is_numeric($key)) {
127 127
                     return $this->where($value);
128 128
                 }
129 129
                 return $this->where($key, $value);
130 130
             }
131
-        }else{
131
+        }else {
132 132
             $criteria = $this->validate_criteria($criteria);
133 133
             $value = $this->parse_value($value);
134 134
 
135
-            if($value === null || $value === ''){
135
+            if ($value === null || $value === '') {
136 136
                 $this->query->push([$criteria]);
137
-            }else{
137
+            }else {
138 138
                 $this->query->push([$criteria, $value]);
139 139
             }
140 140
         }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function orWhere(\Closure $closure = null) {
151 151
         $this->query->push(['OR']);
152
-        if($closure !== null) $closure($this);
152
+        if ($closure !== null) $closure($this);
153 153
 
154 154
         return $this;
155 155
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function andWhere(\Closure $closure = null) {
163 163
         $this->query->push(['AND']);
164
-        if($closure !== null) $closure($this);
164
+        if ($closure !== null) $closure($this);
165 165
 
166 166
         return $this;
167 167
     }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
      * @return WhereQuery
402 402
      * @throws InvalidWhereQueryCriteriaException
403 403
      */
404
-    public function whereNoXSpam(){
404
+    public function whereNoXSpam() {
405 405
         return $this->where("CUSTOM X-Spam-Flag NO");
406 406
     }
407 407
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
      * @return WhereQuery
410 410
      * @throws InvalidWhereQueryCriteriaException
411 411
      */
412
-    public function whereIsXSpam(){
412
+    public function whereIsXSpam() {
413 413
         return $this->where("CUSTOM X-Spam-Flag YES");
414 414
     }
415 415
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      * @return WhereQuery
422 422
      * @throws InvalidWhereQueryCriteriaException
423 423
      */
424
-    public function whereHeader($header, $value){
424
+    public function whereHeader($header, $value) {
425 425
         return $this->where("CUSTOM HEADER $header $value");
426 426
     }
427 427
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
      * @return WhereQuery
433 433
      * @throws InvalidWhereQueryCriteriaException
434 434
      */
435
-    public function whereMessageId($messageId){
435
+    public function whereMessageId($messageId) {
436 436
         return $this->whereHeader("Message-ID", $messageId);
437 437
     }
438 438
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
      * @return WhereQuery
444 444
      * @throws InvalidWhereQueryCriteriaException
445 445
      */
446
-    public function whereInReplyTo($messageId){
446
+    public function whereInReplyTo($messageId) {
447 447
         return $this->whereHeader("In-Reply-To", $messageId);
448 448
     }
449 449
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
      * @return WhereQuery
454 454
      * @throws InvalidWhereQueryCriteriaException
455 455
      */
456
-    public function whereLanguage($country_code){
456
+    public function whereLanguage($country_code) {
457 457
         return $this->where("Content-Language $country_code");
458 458
     }
459 459
 }
460 460
\ No newline at end of file
Please login to merge, or discard this patch.
src/Connection/Protocols/LegacyProtocol.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             throw new AuthFailedException($message);
88 88
         }
89 89
 
90
-        if(!$this->stream) {
90
+        if (!$this->stream) {
91 91
             $errors = \imap_errors();
92 92
             $message = implode("; ", (is_array($errors) ? $errors : array()));
93 93
             throw new AuthFailedException($message);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
         if (!$this->cert_validation) {
119 119
             $address .= '/novalidate-cert';
120 120
         }
121
-        if (in_array($this->encryption,['tls', 'notls', 'ssl'])) {
121
+        if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) {
122 122
             $address .= '/'.$this->encryption;
123 123
         } elseif ($this->encryption === "starttls") {
124 124
             $address .= '/tls';
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      *
147 147
      * @return bool
148 148
      */
149
-    public function connected(){
149
+    public function connected() {
150 150
         return !$this->stream;
151 151
     }
152 152
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      *
219 219
      * @return array
220 220
      */
221
-    public function headers($uids, $rfc = "RFC822", $uid = false){
221
+    public function headers($uids, $rfc = "RFC822", $uid = false) {
222 222
         $result = [];
223 223
         $uids = is_array($uids) ? $uids : [$uids];
224 224
         foreach ($uids as $uid) {
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      *
235 235
      * @return array
236 236
      */
237
-    public function flags($uids, $uid = false){
237
+    public function flags($uids, $uid = false) {
238 238
         $result = [];
239 239
         $uids = is_array($uids) ? $uids : [$uids];
240 240
         foreach ($uids as $uid) {
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
             $flags = [];
243 243
             if (is_array($raw_flags) && isset($raw_flags[0])) {
244 244
                 $raw_flags = (array) $raw_flags[0];
245
-                foreach($raw_flags as $flag => $value) {
246
-                    if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){
245
+                foreach ($raw_flags as $flag => $value) {
246
+                    if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) {
247 247
                         $flags[] = "\\".ucfirst($flag);
248 248
                     }
249 249
                 }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         if ($id === null) {
265 265
             $overview = $this->overview("1:*");
266 266
             $uids = [];
267
-            foreach($overview as $set){
267
+            foreach ($overview as $set) {
268 268
                 $uids[$set->msgno] = $set->uid;
269 269
             }
270 270
             return $uids;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      * @return array
291 291
      */
292 292
     public function overview($sequence, $uid = false) {
293
-        return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::FT_UID : IMAP::NIL);
293
+        return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::FT_UID : IMAP::NIL);
294 294
     }
295 295
 
296 296
     /**
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
         $result = [];
306 306
 
307 307
         $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder);
308
-        if(is_array($items)){
308
+        if (is_array($items)) {
309 309
             foreach ($items as $item) {
310 310
                 $name = $this->decodeFolderName($item->name);
311 311
                 $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []];
312 312
             }
313
-        }else{
313
+        }else {
314 314
             throw new RuntimeException(\imap_last_error());
315 315
         }
316 316
 
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
     public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) {
333 333
         $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags);
334 334
 
335
-        if ($mode == "+"){
335
+        if ($mode == "+") {
336 336
             $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL);
337
-        }else{
337
+        }else {
338 338
             $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL);
339 339
         }
340 340
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      */
357 357
     public function appendMessage($folder, $message, $flags = null, $date = null) {
358 358
         if ($date != null) {
359
-            if ($date instanceof \Carbon\Carbon){
359
+            if ($date instanceof \Carbon\Carbon) {
360 360
                 $date = $date->format('d-M-Y H:i:s O');
361 361
             }
362 362
             return \imap_append($this->stream, $folder, $message, $flags, $date);
@@ -493,14 +493,14 @@  discard block
 block discarded – undo
493 493
     /**
494 494
      * Enable the debug mode
495 495
      */
496
-    public function enableDebug(){
496
+    public function enableDebug() {
497 497
         $this->debug = true;
498 498
     }
499 499
 
500 500
     /**
501 501
      * Disable the debug mode
502 502
      */
503
-    public function disableDebug(){
503
+    public function disableDebug() {
504 504
         $this->debug = false;
505 505
     }
506 506
 
Please login to merge, or discard this patch.
src/Attribute.php 1 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/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/Query/Query.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
         $this->setClient($client);
81 81
 
82 82
         $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN);
83
-        if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
83
+        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
84 84
 
85 85
         if (ClientManager::get('options.fetch_order') === 'desc') {
86 86
             $this->fetch_order = 'desc';
87
-        } else {
87
+        }else {
88 88
             $this->fetch_order = 'asc';
89 89
         }
90 90
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     /**
99 99
      * Instance boot method for additional functionality
100 100
      */
101
-    protected function boot(){}
101
+    protected function boot() {}
102 102
 
103 103
     /**
104 104
      * Parse a given value
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
      *
107 107
      * @return string
108 108
      */
109
-    protected function parse_value($value){
110
-        switch(true){
109
+    protected function parse_value($value) {
110
+        switch (true) {
111 111
             case $value instanceof \Carbon\Carbon:
112 112
                 $value = $value->format($this->date_format);
113 113
                 break;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      * @throws MessageSearchValidationException
125 125
      */
126 126
     protected function parse_date($date) {
127
-        if($date instanceof \Carbon\Carbon) return $date;
127
+        if ($date instanceof \Carbon\Carbon) return $date;
128 128
 
129 129
         try {
130 130
             $date = Carbon::parse($date);
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
      * @return Collection
176 176
      * @throws GetMessagesFailedException
177 177
      */
178
-    protected function search(){
178
+    protected function search() {
179 179
         $this->generate_query();
180 180
 
181 181
         try {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
                     $raw_flag = isset($raw_flags[$uid]) ? $raw_flags[$uid] : [];
241 241
 
242 242
                     $message = Message::make($uid, $msglist, $this->getClient(), $raw_header, $raw_content, $raw_flag, $this->getFetchOptions(), $this->sequence);
243
-                    switch ($message_key){
243
+                    switch ($message_key) {
244 244
                         case 'number':
245 245
                             $key = $message->getMessageNo();
246 246
                             break;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 
263 263
             return $messages;
264 264
         } catch (\Exception $e) {
265
-            throw new GetMessagesFailedException($e->getMessage(),0, $e);
265
+            throw new GetMessagesFailedException($e->getMessage(), 0, $e);
266 266
         }
267 267
     }
268 268
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
282 282
      * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException
283 283
      */
284
-    public function getMessage($uid, $msglist = null, $sequence = null){
284
+    public function getMessage($uid, $msglist = null, $sequence = null) {
285 285
         return new Message($uid, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags(), $sequence ? $sequence : $this->sequence);
286 286
     }
287 287
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
      * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
300 300
      * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException
301 301
      */
302
-    public function getMessageByMsgn($msgn, $msglist = null){
302
+    public function getMessageByMsgn($msgn, $msglist = null) {
303 303
         return $this->getMessage($msgn, $msglist, IMAP::ST_MSGN);
304 304
     }
305 305
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
317 317
      * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException
318 318
      */
319
-    public function getMessageByUid($uid){
319
+    public function getMessageByUid($uid) {
320 320
         return $this->getMessage($uid, null, IMAP::ST_UID);
321 321
     }
322 322
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      * @return LengthAwarePaginator
330 330
      * @throws GetMessagesFailedException
331 331
      */
332
-    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
332
+    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') {
333 333
         if (
334 334
                $page === null
335 335
             && isset($_GET[$page_name])
@@ -355,10 +355,10 @@  discard block
 block discarded – undo
355 355
         $this->query->each(function($statement) use(&$query) {
356 356
             if (count($statement) == 1) {
357 357
                 $query .= $statement[0];
358
-            } else {
359
-                if($statement[1] === null){
358
+            }else {
359
+                if ($statement[1] === null) {
360 360
                     $query .= $statement[0];
361
-                }else{
361
+                }else {
362 362
                     $query .= $statement[0].' "'.$statement[1].'"';
363 363
                 }
364 364
             }
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
      * @return $this
389 389
      */
390 390
     public function limit($limit, $page = 1) {
391
-        if($page >= 1) $this->page = $page;
391
+        if ($page >= 1) $this->page = $page;
392 392
         $this->limit = $limit;
393 393
 
394 394
         return $this;
Please login to merge, or discard this patch.
src/Folder.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         $this->setDelimiter($delimiter);
127 127
         $this->path      = $folder_name;
128
-        $this->full_name  = $this->decodeName($folder_name);
128
+        $this->full_name = $this->decodeName($folder_name);
129 129
         $this->name      = $this->getSimpleName($this->delimiter, $this->full_name);
130 130
 
131 131
         $this->parseAttributes($attributes);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      * @throws Exceptions\ConnectionFailedException
140 140
      * @throws Exceptions\RuntimeException
141 141
      */
142
-    public function query($charset = 'UTF-8'){
142
+    public function query($charset = 'UTF-8') {
143 143
         $this->getClient()->checkConnection();
144 144
         $this->getClient()->openFolder($this->path);
145 145
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @throws Exceptions\ConnectionFailedException
152 152
      * @throws Exceptions\RuntimeException
153 153
      */
154
-    public function search($charset = 'UTF-8'){
154
+    public function search($charset = 'UTF-8') {
155 155
         return $this->query($charset);
156 156
     }
157 157
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      * @throws Exceptions\ConnectionFailedException
161 161
      * @throws Exceptions\RuntimeException
162 162
      */
163
-    public function messages($charset = 'UTF-8'){
163
+    public function messages($charset = 'UTF-8') {
164 164
         return $this->query($charset);
165 165
     }
166 166
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
     public function move($new_name, $expunge = true) {
236 236
         $this->client->checkConnection();
237 237
         $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name);
238
-        if($expunge) $this->client->expunge();
238
+        if ($expunge) $this->client->expunge();
239 239
 
240 240
         $folder = $this->client->getFolder($new_name);
241 241
         $event = $this->getEvent("folder", "moved");
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
      * @throws ConnectionFailedException
253 253
      * @throws Exceptions\RuntimeException
254 254
      */
255
-    public function overview($sequence = null){
255
+    public function overview($sequence = null) {
256 256
         $this->client->openFolder($this->path);
257 257
         $sequence = $sequence === null ? "1:*" : $sequence;
258 258
         $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
          */
278 278
 
279 279
         if ($internal_date != null) {
280
-            if ($internal_date instanceof Carbon){
280
+            if ($internal_date instanceof Carbon) {
281 281
                 $internal_date = $internal_date->format('d-M-Y H:i:s O');
282 282
             }
283 283
         }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      */
312 312
     public function delete($expunge = true) {
313 313
         $status = $this->client->getConnection()->deleteFolder($this->path);
314
-        if($expunge) $this->client->expunge();
314
+        if ($expunge) $this->client->expunge();
315 315
 
316 316
         $event = $this->getEvent("folder", "deleted");
317 317
         $event::dispatch($this);
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
             try {
372 372
                 $line = $connection->nextLine();
373 373
                 if (($pos = strpos($line, "EXISTS")) !== false) {
374
-                    $msgn = (int) substr($line, 2, $pos -2);
374
+                    $msgn = (int) substr($line, 2, $pos - 2);
375 375
                     $connection->done();
376 376
 
377 377
                     $this->client->openFolder($this->path, true);
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
 
385 385
                     $connection->idle();
386 386
                 }
387
-            }catch (Exceptions\RuntimeException $e) {
388
-                if(strpos($e->getMessage(), "connection closed") === false) {
387
+            } catch (Exceptions\RuntimeException $e) {
388
+                if (strpos($e->getMessage(), "connection closed") === false) {
389 389
                     throw $e;
390 390
                 }
391 391
                 if ($auto_reconnect === true) {
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
      * Set the delimiter
431 431
      * @param $delimiter
432 432
      */
433
-    public function setDelimiter($delimiter){
434
-        if(in_array($delimiter, [null, '', ' ', false]) === true) {
433
+    public function setDelimiter($delimiter) {
434
+        if (in_array($delimiter, [null, '', ' ', false]) === true) {
435 435
             $delimiter = ClientManager::get('options.delimiter', '/');
436 436
         }
437 437
 
Please login to merge, or discard this patch.
src/Client.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
      * @param array $config
202 202
      * @param array $default_config
203 203
      */
204
-    private function setAccountConfig($key, $config, $default_config){
204
+    private function setAccountConfig($key, $config, $default_config) {
205 205
         $value = $this->default_account_config[$key];
206
-        if(isset($config[$key])) {
206
+        if (isset($config[$key])) {
207 207
             $value = $config[$key];
208
-        }elseif(isset($default_config[$key])) {
208
+        }elseif (isset($default_config[$key])) {
209 209
             $value = $default_config[$key];
210 210
         }
211 211
         $this->$key = $value;
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
      */
218 218
     protected function setEventsFromConfig($config) {
219 219
         $this->events = ClientManager::get("events");
220
-        if(isset($config['events'])){
221
-            if(isset($config['events'])) {
222
-                foreach($config['events'] as $section => $events) {
220
+        if (isset($config['events'])) {
221
+            if (isset($config['events'])) {
222
+                foreach ($config['events'] as $section => $events) {
223 223
                     $this->events[$section] = array_merge($this->events[$section], $events);
224 224
                 }
225 225
             }
@@ -233,45 +233,45 @@  discard block
 block discarded – undo
233 233
      * @throws MaskNotFoundException
234 234
      */
235 235
     protected function setMaskFromConfig($config) {
236
-        $default_config  = ClientManager::get("masks");
236
+        $default_config = ClientManager::get("masks");
237 237
 
238
-        if(isset($config['masks'])){
239
-            if(isset($config['masks']['message'])) {
240
-                if(class_exists($config['masks']['message'])) {
238
+        if (isset($config['masks'])) {
239
+            if (isset($config['masks']['message'])) {
240
+                if (class_exists($config['masks']['message'])) {
241 241
                     $this->default_message_mask = $config['masks']['message'];
242
-                }else{
242
+                }else {
243 243
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
244 244
                 }
245
-            }else{
246
-                if(class_exists($default_config['message'])) {
245
+            }else {
246
+                if (class_exists($default_config['message'])) {
247 247
                     $this->default_message_mask = $default_config['message'];
248
-                }else{
248
+                }else {
249 249
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
250 250
                 }
251 251
             }
252
-            if(isset($config['masks']['attachment'])) {
253
-                if(class_exists($config['masks']['attachment'])) {
252
+            if (isset($config['masks']['attachment'])) {
253
+                if (class_exists($config['masks']['attachment'])) {
254 254
                     $this->default_message_mask = $config['masks']['attachment'];
255
-                }else{
255
+                }else {
256 256
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
257 257
                 }
258
-            }else{
259
-                if(class_exists($default_config['attachment'])) {
258
+            }else {
259
+                if (class_exists($default_config['attachment'])) {
260 260
                     $this->default_message_mask = $default_config['attachment'];
261
-                }else{
261
+                }else {
262 262
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
263 263
                 }
264 264
             }
265
-        }else{
266
-            if(class_exists($default_config['message'])) {
265
+        }else {
266
+            if (class_exists($default_config['message'])) {
267 267
                 $this->default_message_mask = $default_config['message'];
268
-            }else{
268
+            }else {
269 269
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
270 270
             }
271 271
 
272
-            if(class_exists($default_config['attachment'])) {
272
+            if (class_exists($default_config['attachment'])) {
273 273
                 $this->default_message_mask = $default_config['attachment'];
274
-            }else{
274
+            }else {
275 275
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
276 276
             }
277 277
         }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
336 336
             $this->connection->setConnectionTimeout($this->timeout);
337 337
             $this->connection->setProxy($this->proxy);
338
-        }else{
338
+        }else {
339 339
             if (extension_loaded('imap') === false) {
340 340
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
341 341
             }
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
459 459
         $items = $this->connection->folders('', $pattern);
460 460
 
461
-        if(is_array($items)){
461
+        if (is_array($items)) {
462 462
             foreach ($items as $folder_name => $item) {
463 463
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
464 464
 
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
             }
474 474
 
475 475
             return $folders;
476
-        }else{
476
+        }else {
477 477
             throw new FolderFetchingException("failed to fetch any folders");
478 478
         }
479 479
     }
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
         $this->checkConnection();
512 512
         $status = $this->connection->createFolder($folder);
513 513
 
514
-        if($expunge) $this->expunge();
514
+        if ($expunge) $this->expunge();
515 515
 
516 516
         $folder = $this->getFolder($folder);
517
-        if($status && $folder) {
517
+        if ($status && $folder) {
518 518
             $event = $this->getEvent("folder", "new");
519 519
             $event::dispatch($folder);
520 520
         }
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
      *
541 541
      * @return Folder
542 542
      */
543
-    public function getFolderPath(){
543
+    public function getFolderPath() {
544 544
         return $this->active_folder;
545 545
     }
546 546
 
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
      *
597 597
      * @return int
598 598
      */
599
-    public function getTimeout($type){
599
+    public function getTimeout($type) {
600 600
         return $this->connection->getConnectionTimeout();
601 601
     }
602 602
 
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
      *
606 606
      * @return string
607 607
      */
608
-    public function getDefaultMessageMask(){
608
+    public function getDefaultMessageMask() {
609 609
         return $this->default_message_mask;
610 610
     }
611 611
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
      *
616 616
      * @return array
617 617
      */
618
-    public function getDefaultEvents($section){
618
+    public function getDefaultEvents($section) {
619 619
         return $this->events[$section];
620 620
     }
621 621
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
      * @throws MaskNotFoundException
628 628
      */
629 629
     public function setDefaultMessageMask($mask) {
630
-        if(class_exists($mask)) {
630
+        if (class_exists($mask)) {
631 631
             $this->default_message_mask = $mask;
632 632
 
633 633
             return $this;
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
      *
642 642
      * @return string
643 643
      */
644
-    public function getDefaultAttachmentMask(){
644
+    public function getDefaultAttachmentMask() {
645 645
         return $this->default_attachment_mask;
646 646
     }
647 647
 
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
      * @throws MaskNotFoundException
654 654
      */
655 655
     public function setDefaultAttachmentMask($mask) {
656
-        if(class_exists($mask)) {
656
+        if (class_exists($mask)) {
657 657
             $this->default_attachment_mask = $mask;
658 658
 
659 659
             return $this;
Please login to merge, or discard this patch.
src/Header.php 1 patch
Spacing   +49 added lines, -49 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
      * @throws InvalidMessageDateException
174 174
      */
175
-    protected function parse(){
175
+    protected function parse() {
176 176
         $header = $this->rfc822_parse_headers($this->raw);
177 177
 
178 178
         $this->extractAddresses($header);
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         $this->parseDate($header);
191 191
         foreach ($header as $key => $value) {
192 192
             $key = trim(rtrim(strtolower($key)));
193
-            if(!isset($this->attributes[$key])){
193
+            if (!isset($this->attributes[$key])) {
194 194
                 $this->set($key, $value);
195 195
             }
196 196
         }
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
      *
207 207
      * @return object
208 208
      */
209
-    public function rfc822_parse_headers($raw_headers){
209
+    public function rfc822_parse_headers($raw_headers) {
210 210
         $headers = [];
211 211
         $imap_headers = [];
212 212
         if (extension_loaded('imap')) {
213 213
             $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw);
214
-            foreach($raw_imap_headers as $key => $values) {
214
+            foreach ($raw_imap_headers as $key => $values) {
215 215
                 $key = str_replace("-", "_", $key);
216 216
                 $imap_headers[$key] = $values;
217 217
             }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
         $lines = explode("\r\n", $raw_headers);
221 221
         $prev_header = null;
222
-        foreach($lines as $line) {
222
+        foreach ($lines as $line) {
223 223
             if (substr($line, 0, 1) === "\n") {
224 224
                 $line = substr($line, 1);
225 225
             }
@@ -239,19 +239,19 @@  discard block
 block discarded – undo
239 239
                     }
240 240
                     if (is_array($headers[$prev_header])) {
241 241
                         $headers[$prev_header][] = $line;
242
-                    }else{
242
+                    }else {
243 243
                         $headers[$prev_header] .= $line;
244 244
                     }
245 245
                 }
246
-            }else{
246
+            }else {
247 247
                 if (($pos = strpos($line, ":")) > 0) {
248 248
                     $key = trim(rtrim(strtolower(substr($line, 0, $pos))));
249 249
                     $key = str_replace("-", "_", $key);
250 250
 
251 251
                     $value = trim(rtrim(substr($line, $pos + 1)));
252 252
                     if (isset($headers[$key])) {
253
-                        $headers[$key][]  = $value;
254
-                    }else{
253
+                        $headers[$key][] = $value;
254
+                    }else {
255 255
                         $headers[$key] = [$value];
256 256
                     }
257 257
                     $prev_header = $key;
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
             }
260 260
         }
261 261
 
262
-        foreach($headers as $key => $values) {
262
+        foreach ($headers as $key => $values) {
263 263
             if (isset($imap_headers[$key])) continue;
264 264
             $value = null;
265
-            switch($key){
265
+            switch ($key) {
266 266
                 case 'from':
267 267
                 case 'to':
268 268
                 case 'cc':
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                     break;
278 278
                 default:
279 279
                     if (is_array($values)) {
280
-                        foreach($values as $k => $v) {
280
+                        foreach ($values as $k => $v) {
281 281
                             if ($v == "") {
282 282
                                 unset($values[$k]);
283 283
                             }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                             $value = implode(" ", $values);
290 290
                         } elseif ($available_values > 2) {
291 291
                             $value = array_values($values);
292
-                        } else {
292
+                        }else {
293 293
                             $value = "";
294 294
                         }
295 295
                     }
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
      * @return array The decoded elements are returned in an array of objects, where each
310 310
      * object has two properties, charset and text.
311 311
      */
312
-    public function mime_header_decode($text){
312
+    public function mime_header_decode($text) {
313 313
         if (extension_loaded('imap')) {
314 314
             return \imap_mime_header_decode($text);
315 315
         }
316 316
         $charset = $this->getEncoding($text);
317
-        return [(object)[
317
+        return [(object) [
318 318
             "charset" => $charset,
319 319
             "text" => $this->convertEncoding($text, $charset)
320 320
         ]];
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
         try {
369 369
             if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
370 370
                 return iconv($from, $to, $str);
371
-            } else {
371
+            }else {
372 372
                 if (!$from) {
373 373
                     return mb_convert_encoding($str, $to);
374 374
                 }
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             if (strstr($from, '-')) {
379 379
                 $from = str_replace('-', '', $from);
380 380
                 return $this->convertEncoding($str, $from, $to);
381
-            } else {
381
+            }else {
382 382
                 return $str;
383 383
             }
384 384
         }
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
             }
400 400
         }elseif (property_exists($structure, 'charset')) {
401 401
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
402
-        }elseif (is_string($structure) === true){
402
+        }elseif (is_string($structure) === true) {
403 403
             return mb_detect_encoding($structure);
404 404
         }
405 405
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         if ($value !== null) {
433 433
             $is_utf8_base = $this->is_uft8($value);
434 434
 
435
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
435
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
436 436
                 $value = \imap_utf8($value);
437 437
                 $is_utf8_base = $this->is_uft8($value);
438 438
                 if ($is_utf8_base) {
@@ -441,14 +441,14 @@  discard block
 block discarded – undo
441 441
                 if ($this->notDecoded($original_value, $value)) {
442 442
                     $decoded_value = $this->mime_header_decode($value);
443 443
                     if (count($decoded_value) > 0) {
444
-                        if(property_exists($decoded_value[0], "text")) {
444
+                        if (property_exists($decoded_value[0], "text")) {
445 445
                             $value = $decoded_value[0]->text;
446 446
                         }
447 447
                     }
448 448
                 }
449
-            }elseif($decoder === 'iconv' && $is_utf8_base) {
449
+            }elseif ($decoder === 'iconv' && $is_utf8_base) {
450 450
                 $value = iconv_mime_decode($value);
451
-            }elseif($is_utf8_base){
451
+            }elseif ($is_utf8_base) {
452 452
                 $value = mb_decode_mimeheader($value);
453 453
             }
454 454
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
      * @return array
472 472
      */
473 473
     private function decodeArray($values) {
474
-        foreach($values as $key => $value) {
474
+        foreach ($values as $key => $value) {
475 475
             $values[$key] = $this->decode($value);
476 476
         }
477 477
         return $values;
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
      * Try to extract the priority from a given raw header string
482 482
      */
483 483
     private function findPriority() {
484
-        if(($priority = $this->get("x_priority")) === null) return;
485
-        switch((int)"$priority"){
484
+        if (($priority = $this->get("x_priority")) === null) return;
485
+        switch ((int) "$priority") {
486 486
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
487 487
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
488 488
                 break;
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
      */
515 515
     private function decodeAddresses($values) {
516 516
         $addresses = [];
517
-        foreach($values as $address) {
517
+        foreach ($values as $address) {
518 518
             $address = trim(rtrim($address));
519 519
             if (strpos($address, ",") == strlen($address) - 1) {
520 520
                 $address = substr($address, 0, -1);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                 '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/',
524 524
                 $address,
525 525
                 $matches
526
-            )){
526
+            )) {
527 527
                 $name = trim(rtrim($matches["name"]));
528 528
                 $email = trim(rtrim($matches["email"]));
529 529
                 list($mailbox, $host) = array_pad(explode("@", $email), 2, null);
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
      * @param object $header
543 543
      */
544 544
     private function extractAddresses($header) {
545
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){
545
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) {
546 546
             if (property_exists($header, $key)) {
547 547
                 $this->set($key, $this->parseAddresses($header->$key));
548 548
             }
@@ -573,10 +573,10 @@  discard block
 block discarded – undo
573 573
             }
574 574
             if (!property_exists($address, 'personal')) {
575 575
                 $address->personal = false;
576
-            } else {
576
+            }else {
577 577
                 $personalParts = $this->mime_header_decode($address->personal);
578 578
 
579
-                if(is_array($personalParts)) {
579
+                if (is_array($personalParts)) {
580 580
                     $address->personal = '';
581 581
                     foreach ($personalParts as $p) {
582 582
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -600,23 +600,23 @@  discard block
 block discarded – undo
600 600
     /**
601 601
      * Search and extract potential header extensions
602 602
      */
603
-    private function extractHeaderExtensions(){
603
+    private function extractHeaderExtensions() {
604 604
         foreach ($this->attributes as $key => $value) {
605 605
             if (is_array($value)) {
606 606
                 $value = implode(", ", $value);
607
-            }else{
608
-                $value = (string)$value;
607
+            }else {
608
+                $value = (string) $value;
609 609
             }
610 610
             // Only parse strings and don't parse any attributes like the user-agent
611 611
             if (in_array($key, ["user_agent"]) === false) {
612
-                if (($pos = strpos($value, ";")) !== false){
612
+                if (($pos = strpos($value, ";")) !== false) {
613 613
                     $original = substr($value, 0, $pos);
614 614
                     $this->set($key, trim(rtrim($original)), true);
615 615
 
616 616
                     // Get all potential extensions
617 617
                     $extensions = explode(";", substr($value, $pos + 1));
618
-                    foreach($extensions as $extension) {
619
-                        if (($pos = strpos($extension, "=")) !== false){
618
+                    foreach ($extensions as $extension) {
619
+                        if (($pos = strpos($extension, "=")) !== false) {
620 620
                             $key = substr($extension, 0, $pos);
621 621
                             $key = trim(rtrim(strtolower($key)));
622 622
 
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
             $parsed_date = null;
660 660
             $date = $header->date;
661 661
 
662
-            if(preg_match('/\+0580/', $date)) {
662
+            if (preg_match('/\+0580/', $date)) {
663 663
                 $date = str_replace('+0580', '+0530', $date);
664 664
             }
665 665
 
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
                         $date = trim(array_pop($array));
683 683
                         break;
684 684
                 }
685
-                try{
685
+                try {
686 686
                     $parsed_date = Carbon::parse($date);
687 687
                 } catch (\Exception $_e) {
688 688
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e);
Please login to merge, or discard this patch.