Completed
Push — master ( 92912a...d77b64 )
by Malte
02:03
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/Client.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
      * @param array $config
195 195
      * @param array $default_config
196 196
      */
197
-    private function setAccountConfig($key, $config, $default_config){
197
+    private function setAccountConfig($key, $config, $default_config) {
198 198
         $value = $this->default_account_config[$key];
199
-        if(isset($config[$key])) {
199
+        if (isset($config[$key])) {
200 200
             $value = $config[$key];
201
-        }elseif(isset($default_config[$key])) {
201
+        }elseif (isset($default_config[$key])) {
202 202
             $value = $default_config[$key];
203 203
         }
204 204
         $this->$key = $value;
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
      */
211 211
     protected function setEventsFromConfig($config) {
212 212
         $this->events = ClientManager::get("events");
213
-        if(isset($config['events'])){
214
-            if(isset($config['events'])) {
215
-                foreach($config['events'] as $section => $events) {
213
+        if (isset($config['events'])) {
214
+            if (isset($config['events'])) {
215
+                foreach ($config['events'] as $section => $events) {
216 216
                     $this->events[$section] = array_merge($this->events[$section], $events);
217 217
                 }
218 218
             }
@@ -226,45 +226,45 @@  discard block
 block discarded – undo
226 226
      * @throws MaskNotFoundException
227 227
      */
228 228
     protected function setMaskFromConfig($config) {
229
-        $default_config  = ClientManager::get("masks");
229
+        $default_config = ClientManager::get("masks");
230 230
 
231
-        if(isset($config['masks'])){
232
-            if(isset($config['masks']['message'])) {
233
-                if(class_exists($config['masks']['message'])) {
231
+        if (isset($config['masks'])) {
232
+            if (isset($config['masks']['message'])) {
233
+                if (class_exists($config['masks']['message'])) {
234 234
                     $this->default_message_mask = $config['masks']['message'];
235
-                }else{
235
+                }else {
236 236
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
237 237
                 }
238
-            }else{
239
-                if(class_exists($default_config['message'])) {
238
+            }else {
239
+                if (class_exists($default_config['message'])) {
240 240
                     $this->default_message_mask = $default_config['message'];
241
-                }else{
241
+                }else {
242 242
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
243 243
                 }
244 244
             }
245
-            if(isset($config['masks']['attachment'])) {
246
-                if(class_exists($config['masks']['attachment'])) {
245
+            if (isset($config['masks']['attachment'])) {
246
+                if (class_exists($config['masks']['attachment'])) {
247 247
                     $this->default_message_mask = $config['masks']['attachment'];
248
-                }else{
248
+                }else {
249 249
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
250 250
                 }
251
-            }else{
252
-                if(class_exists($default_config['attachment'])) {
251
+            }else {
252
+                if (class_exists($default_config['attachment'])) {
253 253
                     $this->default_message_mask = $default_config['attachment'];
254
-                }else{
254
+                }else {
255 255
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
256 256
                 }
257 257
             }
258
-        }else{
259
-            if(class_exists($default_config['message'])) {
258
+        }else {
259
+            if (class_exists($default_config['message'])) {
260 260
                 $this->default_message_mask = $default_config['message'];
261
-            }else{
261
+            }else {
262 262
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
263 263
             }
264 264
 
265
-            if(class_exists($default_config['attachment'])) {
265
+            if (class_exists($default_config['attachment'])) {
266 266
                 $this->default_message_mask = $default_config['attachment'];
267
-            }else{
267
+            }else {
268 268
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
269 269
             }
270 270
         }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
330 330
             $this->connection->setConnectionTimeout($timeout);
331 331
             $this->connection->setProxy($this->proxy);
332
-        }else{
332
+        }else {
333 333
             if (extension_loaded('imap') === false) {
334 334
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
335 335
             }
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
443 443
         $items = $this->connection->folders('', $pattern);
444 444
 
445
-        if(is_array($items)){
445
+        if (is_array($items)) {
446 446
             foreach ($items as $folder_name => $item) {
447 447
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
448 448
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             }
458 458
 
459 459
             return $folders;
460
-        }else{
460
+        }else {
461 461
             throw new FolderFetchingException("failed to fetch any folders");
462 462
         }
463 463
     }
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
         $this->checkConnection();
494 494
         $status = $this->connection->createFolder($folder);
495 495
 
496
-        if($expunge) $this->expunge();
496
+        if ($expunge) $this->expunge();
497 497
 
498 498
         $folder = $this->getFolder($folder);
499
-        if($status && $folder) {
499
+        if ($status && $folder) {
500 500
             $event = $this->getEvent("folder", "new");
501 501
             $event::dispatch($folder);
502 502
         }
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
      *
522 522
      * @return Folder
523 523
      */
524
-    public function getFolderPath(){
524
+    public function getFolderPath() {
525 525
         return $this->active_folder;
526 526
     }
527 527
 
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
      *
576 576
      * @return int
577 577
      */
578
-    public function getTimeout($type){
578
+    public function getTimeout($type) {
579 579
         return $this->connection->getConnectionTimeout();
580 580
     }
581 581
 
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
      *
585 585
      * @return string
586 586
      */
587
-    public function getDefaultMessageMask(){
587
+    public function getDefaultMessageMask() {
588 588
         return $this->default_message_mask;
589 589
     }
590 590
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
      *
595 595
      * @return array
596 596
      */
597
-    public function getDefaultEvents($section){
597
+    public function getDefaultEvents($section) {
598 598
         return $this->events[$section];
599 599
     }
600 600
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      * @throws MaskNotFoundException
607 607
      */
608 608
     public function setDefaultMessageMask($mask) {
609
-        if(class_exists($mask)) {
609
+        if (class_exists($mask)) {
610 610
             $this->default_message_mask = $mask;
611 611
 
612 612
             return $this;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
      *
621 621
      * @return string
622 622
      */
623
-    public function getDefaultAttachmentMask(){
623
+    public function getDefaultAttachmentMask() {
624 624
         return $this->default_attachment_mask;
625 625
     }
626 626
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
      * @throws MaskNotFoundException
633 633
      */
634 634
     public function setDefaultAttachmentMask($mask) {
635
-        if(class_exists($mask)) {
635
+        if (class_exists($mask)) {
636 636
             $this->default_attachment_mask = $mask;
637 637
 
638 638
             return $this;
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
         if ($this->type == IMAP::MESSAGE_TYPE_TEXT &&
303 303
             ($this->ifdisposition == 0 ||
304 304
                 (empty($this->disposition) || !in_array(strtolower($this->disposition), ClientManager::get('options.dispositions')))
Please login to merge, or discard this patch.
src/Structure.php 1 patch
Spacing   +14 added lines, -14 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,13 +85,13 @@  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
 
90 90
         $content_type = $this->header->get("content_type");
91 91
         $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type;
92
-        if(stripos($content_type, 'multipart') === 0) {
92
+        if (stripos($content_type, 'multipart') === 0) {
93 93
             $this->type = IMAP::MESSAGE_TYPE_MULTIPART;
94
-        }else{
94
+        }else {
95 95
             $this->type = IMAP::MESSAGE_TYPE_TEXT;
96 96
         }
97 97
     }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     /**
100 100
      * Determine the message content type
101 101
      */
102
-    public function getBoundary(){
102
+    public function getBoundary() {
103 103
         $boundary = $this->header->find("/boundary=\"?([^\"]*)[\";\s]/");
104 104
         return str_replace('"', '', $boundary);
105 105
     }
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
      * @throws MessageContentFetchingException
112 112
      * @throws InvalidMessageDateException
113 113
      */
114
-    public function find_parts(){
115
-        if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
116
-            if (($boundary = $this->getBoundary()) === null)  {
114
+    public function find_parts() {
115
+        if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
116
+            if (($boundary = $this->getBoundary()) === null) {
117 117
                 throw new MessageContentFetchingException("no content found", 0);
118 118
             }
119 119
 
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
             ];
123 123
 
124 124
             if (preg_match("/boundary\=\"?(.*)\"?/", $this->raw, $match) == 1) {
125
-                if(is_array($match[1])){
126
-                    foreach($match[1] as $matched){
125
+                if (is_array($match[1])) {
126
+                    foreach ($match[1] as $matched) {
127 127
                         $boundaries[] = str_replace('"', '', $matched);
128 128
                     }
129
-                }else{
130
-                    if(!empty($match[1])) {
129
+                }else {
130
+                    if (!empty($match[1])) {
131 131
                         $boundaries[] = str_replace('"', '', $match[1]);
132 132
                     }
133 133
                 }
134 134
             }
135 135
 
136
-            $raw_parts = explode( $boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw) );
136
+            $raw_parts = explode($boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw));
137 137
             $parts = [];
138 138
             $part_number = 0;
139
-            foreach($raw_parts as $part) {
139
+            foreach ($raw_parts as $part) {
140 140
                 $part = trim(rtrim($part));
141 141
                 if ($part !== "--") {
142 142
                     $parts[] = new Part($part, null, $part_number);
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/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);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @return WhereQuery
139 139
      * @throws Exceptions\ConnectionFailedException
140 140
      */
141
-    public function query($charset = 'UTF-8'){
141
+    public function query($charset = 'UTF-8') {
142 142
         $this->getClient()->checkConnection();
143 143
         $this->getClient()->openFolder($this->path);
144 144
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      * @inheritdoc self::query($charset = 'UTF-8')
150 150
      * @throws Exceptions\ConnectionFailedException
151 151
      */
152
-    public function search($charset = 'UTF-8'){
152
+    public function search($charset = 'UTF-8') {
153 153
         return $this->query($charset);
154 154
     }
155 155
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      * @inheritdoc self::query($charset = 'UTF-8')
158 158
      * @throws Exceptions\ConnectionFailedException
159 159
      */
160
-    public function messages($charset = 'UTF-8'){
160
+    public function messages($charset = 'UTF-8') {
161 161
         return $this->query($charset);
162 162
     }
163 163
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
     public function move($new_name, $expunge = true) {
233 233
         $this->client->checkConnection();
234 234
         $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name);
235
-        if($expunge) $this->client->expunge();
235
+        if ($expunge) $this->client->expunge();
236 236
 
237 237
         $folder = $this->client->getFolder($new_name);
238 238
         $event = $this->getEvent("folder", "moved");
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
      * @return array
249 249
      * @throws ConnectionFailedException
250 250
      */
251
-    public function overview($sequence = null){
251
+    public function overview($sequence = null) {
252 252
         $this->client->openFolder($this->path);
253 253
         $sequence = $sequence === null ? "1:*" : $sequence;
254 254
         $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
          */
274 274
 
275 275
         if ($internal_date != null) {
276
-            if ($internal_date instanceof Carbon){
276
+            if ($internal_date instanceof Carbon) {
277 277
                 $internal_date = $internal_date->format('d-M-Y H:i:s O');
278 278
             }
279 279
         }
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      */
308 308
     public function delete($expunge = true) {
309 309
         $status = $this->client->getConnection()->deleteFolder($this->path);
310
-        if($expunge) $this->client->expunge();
310
+        if ($expunge) $this->client->expunge();
311 311
 
312 312
         $event = $this->getEvent("folder", "deleted");
313 313
         $event::dispatch($this);
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
             try {
363 363
                 $line = $connection->nextLine();
364 364
                 if (($pos = strpos($line, "EXISTS")) !== false) {
365
-                    $msgn = (int) substr($line, 2, $pos -2);
365
+                    $msgn = (int) substr($line, 2, $pos - 2);
366 366
                     $connection->done();
367 367
 
368 368
                     $this->client->openFolder($this->path, true);
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 
375 375
                     $connection->idle();
376 376
                 }
377
-            }catch (Exceptions\RuntimeException $e) {
378
-                if(strpos($e->getMessage(), "connection closed") === false) {
377
+            } catch (Exceptions\RuntimeException $e) {
378
+                if (strpos($e->getMessage(), "connection closed") === false) {
379 379
                     throw $e;
380 380
                 }
381 381
             }
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
      * Set the delimiter
418 418
      * @param $delimiter
419 419
      */
420
-    public function setDelimiter($delimiter){
421
-        if(in_array($delimiter, [null, '', ' ', false]) === true) {
420
+    public function setDelimiter($delimiter) {
421
+        if (in_array($delimiter, [null, '', ' ', false]) === true) {
422 422
             $delimiter = ClientManager::get('options.delimiter', '/');
423 423
         }
424 424
 
Please login to merge, or discard this patch.
src/Connection/Protocols/ImapProtocol.php 1 patch
Spacing   +46 added lines, -46 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
 
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
             // First two chars are still needed for the response code
258 258
             $tokens = [substr($tokens, 0, 2)];
259 259
         }
260
-        if (is_array($lines)){
260
+        if (is_array($lines)) {
261 261
             if ($this->debug) echo "<< ".json_encode($lines)."\n";
262
-        }else{
262
+        }else {
263 263
             if ($this->debug) echo "<< ".$lines."\n";
264 264
         }
265 265
 
@@ -284,27 +284,27 @@  discard block
 block discarded – undo
284 284
     public function sendRequest($command, $tokens = [], &$tag = null) {
285 285
         if (!$tag) {
286 286
             $this->noun++;
287
-            $tag = 'TAG' . $this->noun;
287
+            $tag = 'TAG'.$this->noun;
288 288
         }
289 289
 
290
-        $line = $tag . ' ' . $command;
290
+        $line = $tag.' '.$command;
291 291
 
292 292
         foreach ($tokens as $token) {
293 293
             if (is_array($token)) {
294
-                if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) {
294
+                if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) {
295 295
                     throw new RuntimeException('failed to write - connection closed?');
296 296
                 }
297 297
                 if (!$this->assumedNextLine('+ ')) {
298 298
                     throw new RuntimeException('failed to send literal string');
299 299
                 }
300 300
                 $line = $token[1];
301
-            } else {
302
-                $line .= ' ' . $token;
301
+            }else {
302
+                $line .= ' '.$token;
303 303
             }
304 304
         }
305 305
         if ($this->debug) echo ">> ".$line."\n";
306 306
 
307
-        if (fwrite($this->stream, $line . "\r\n") === false) {
307
+        if (fwrite($this->stream, $line."\r\n") === false) {
308 308
             throw new RuntimeException('failed to write - connection closed?');
309 309
         }
310 310
     }
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
     public function escapeString($string) {
335 335
         if (func_num_args() < 2) {
336 336
             if (strpos($string, "\n") !== false) {
337
-                return ['{' . strlen($string) . '}', $string];
338
-            } else {
339
-                return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
337
+                return ['{'.strlen($string).'}', $string];
338
+            }else {
339
+                return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"';
340 340
             }
341 341
         }
342 342
         $result = [];
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             }
362 362
             $result[] = $this->escapeList($v);
363 363
         }
364
-        return '(' . implode(' ', $result) . ')';
364
+        return '('.implode(' ', $result).')';
365 365
     }
366 366
 
367 367
     /**
@@ -401,12 +401,12 @@  discard block
 block discarded – undo
401 401
                     error_log("got an extra server challenge: $response");
402 402
                     // respond with an empty response.
403 403
                     $this->sendRequest('');
404
-                } else {
404
+                }else {
405 405
                     if (preg_match('/^NO /i', $response) ||
406 406
                         preg_match('/^BAD /i', $response)) {
407 407
                         error_log("got failure response: $response");
408 408
                         return false;
409
-                    } else if (preg_match("/^OK /i", $response)) {
409
+                    }else if (preg_match("/^OK /i", $response)) {
410 410
                         return true;
411 411
                     }
412 412
                 }
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
      *
440 440
      * @return bool
441 441
      */
442
-    public function connected(){
442
+    public function connected() {
443 443
         return (boolean) $this->stream;
444 444
     }
445 445
 
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
                     $result[strtolower($tokens[1])] = $tokens[0];
487 487
                     break;
488 488
                 case '[UIDVALIDITY':
489
-                    $result['uidvalidity'] = (int)$tokens[2];
489
+                    $result['uidvalidity'] = (int) $tokens[2];
490 490
                     break;
491 491
                 case '[UIDNEXT':
492
-                    $result['uidnext'] = (int)$tokens[2];
492
+                    $result['uidnext'] = (int) $tokens[2];
493 493
                     break;
494 494
                 default:
495 495
                     // ignore
@@ -543,17 +543,17 @@  discard block
 block discarded – undo
543 543
         if (is_array($from)) {
544 544
             $set = implode(',', $from);
545 545
         } elseif ($to === null) {
546
-            $set = (int)$from;
546
+            $set = (int) $from;
547 547
         } elseif ($to === INF) {
548
-            $set = (int)$from . ':*';
549
-        } else {
550
-            $set = (int)$from . ':' . (int)$to;
548
+            $set = (int) $from.':*';
549
+        }else {
550
+            $set = (int) $from.':'.(int) $to;
551 551
         }
552 552
 
553
-        $items = (array)$items;
553
+        $items = (array) $items;
554 554
         $itemList = $this->escapeList($items);
555 555
 
556
-        $this->sendRequest(($uid ? 'UID ' : '') . 'FETCH', [$set, $itemList], $tag);
556
+        $this->sendRequest(($uid ? 'UID ' : '').'FETCH', [$set, $itemList], $tag);
557 557
 
558 558
         $result = [];
559 559
         $tokens = null; // define $tokens variable before first use
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
                 $count = count($tokens[2]);
569 569
                 if ($tokens[2][$count - 2] == 'UID') {
570 570
                     $uidKey = $count - 1;
571
-                } else if ($tokens[2][0] == 'UID') {
571
+                }else if ($tokens[2][0] == 'UID') {
572 572
                     $uidKey = 1;
573
-                } else {
573
+                }else {
574 574
                     $uidKey = array_search('UID', $tokens[2]) + 1;
575 575
                 }
576 576
             }
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
                     $data = $tokens[2][1];
587 587
                 } elseif ($uid && $tokens[2][2] == $items[0]) {
588 588
                     $data = $tokens[2][3];
589
-                } else {
589
+                }else {
590 590
                     // maybe the server send an other field we didn't wanted
591 591
                     $count = count($tokens[2]);
592 592
                     // we start with 2, because 0 was already checked
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
                         break;
599 599
                     }
600 600
                 }
601
-            } else {
601
+            }else {
602 602
                 $data = [];
603 603
                 while (key($tokens[2]) !== null) {
604 604
                     $data[current($tokens[2])] = next($tokens[2]);
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
             }
616 616
             if ($uid) {
617 617
                 $result[$tokens[2][$uidKey]] = $data;
618
-            }else{
618
+            }else {
619 619
                 $result[$tokens[0]] = $data;
620 620
             }
621 621
         }
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
      * @return array
650 650
      * @throws RuntimeException
651 651
      */
652
-    public function headers($uids, $rfc = "RFC822", $uid = false){
652
+    public function headers($uids, $rfc = "RFC822", $uid = false) {
653 653
         return $this->fetch(["$rfc.HEADER"], $uids, null, $uid);
654 654
     }
655 655
 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
      * @return array
662 662
      * @throws RuntimeException
663 663
      */
664
-    public function flags($uids, $uid = false){
664
+    public function flags($uids, $uid = false) {
665 665
         return $this->fetch(["FLAGS"], $uids, null, $uid);
666 666
     }
667 667
 
@@ -746,23 +746,23 @@  discard block
 block discarded – undo
746 746
     public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) {
747 747
         $item = 'FLAGS';
748 748
         if ($mode == '+' || $mode == '-') {
749
-            $item = $mode . $item;
749
+            $item = $mode.$item;
750 750
         }
751 751
         if ($silent) {
752 752
             $item .= '.SILENT';
753 753
         }
754 754
 
755 755
         $flags = $this->escapeList($flags);
756
-        $set = (int)$from;
756
+        $set = (int) $from;
757 757
         if ($to !== null) {
758
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
758
+            $set .= ':'.($to == INF ? '*' : (int) $to);
759 759
         }
760 760
 
761 761
         $command = ($uid ? "UID " : "")."STORE";
762 762
         $result = $this->requestAndResponse($command, [$set, $item, $flags], $silent);
763 763
 
764 764
         if ($silent) {
765
-            return (bool)$result;
765
+            return (bool) $result;
766 766
         }
767 767
 
768 768
         $tokens = $result;
@@ -813,9 +813,9 @@  discard block
 block discarded – undo
813 813
      * @throws RuntimeException
814 814
      */
815 815
     public function copyMessage($folder, $from, $to = null, $uid = false) {
816
-        $set = (int)$from;
816
+        $set = (int) $from;
817 817
         if ($to !== null) {
818
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
818
+            $set .= ':'.($to == INF ? '*' : (int) $to);
819 819
         }
820 820
         $command = ($uid ? "UID " : "")."COPY";
821 821
 
@@ -834,9 +834,9 @@  discard block
 block discarded – undo
834 834
      * @throws RuntimeException
835 835
      */
836 836
     public function moveMessage($folder, $from, $to = null, $uid = false) {
837
-        $set = (int)$from;
837
+        $set = (int) $from;
838 838
         if ($to !== null) {
839
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
839
+            $set .= ':'.($to == INF ? '*' : (int) $to);
840 840
         }
841 841
         $command = ($uid ? "UID " : "")."MOVE";
842 842
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
         $ids = [];
1007 1007
         foreach ($uids as $msgn => $v) {
1008 1008
             $id = $uid ? $v : $msgn;
1009
-            if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){
1009
+            if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) {
1010 1010
                 $ids[] = $id;
1011 1011
             }
1012 1012
         }
@@ -1020,14 +1020,14 @@  discard block
 block discarded – undo
1020 1020
     /**
1021 1021
      * Enable the debug mode
1022 1022
      */
1023
-    public function enableDebug(){
1023
+    public function enableDebug() {
1024 1024
         $this->debug = true;
1025 1025
     }
1026 1026
 
1027 1027
     /**
1028 1028
      * Disable the debug mode
1029 1029
      */
1030
-    public function disableDebug(){
1030
+    public function disableDebug() {
1031 1031
         $this->debug = false;
1032 1032
     }
1033 1033
 }
1034 1034
\ No newline at end of file
Please login to merge, or discard this patch.
src/Address.php 1 patch
Spacing   +6 added lines, -6 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,
Please login to merge, or discard this patch.
src/Header.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
      * @throws MethodNotFoundException
74 74
      */
75 75
     public function __call($method, $arguments) {
76
-        if(strtolower(substr($method, 0, 3)) === 'get') {
76
+        if (strtolower(substr($method, 0, 3)) === 'get') {
77 77
             $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3));
78 78
 
79
-            if(in_array($name, array_keys($this->attributes))) {
79
+            if (in_array($name, array_keys($this->attributes))) {
80 80
                 return $this->attributes[$name];
81 81
             }
82 82
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @return Attribute|null
103 103
      */
104 104
     public function get($name) {
105
-        if(isset($this->attributes[$name])) {
105
+        if (isset($this->attributes[$name])) {
106 106
             return $this->attributes[$name];
107 107
         }
108 108
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
      * @return Attribute
119 119
      */
120 120
     public function set($name, $value, $strict = false) {
121
-        if(isset($this->attributes[$name]) && $strict === false) {
121
+        if (isset($this->attributes[$name]) && $strict === false) {
122 122
             $this->attributes[$name]->add($value, true);
123
-        }else{
123
+        }else {
124 124
             $this->attributes[$name] = new Attribute($name, $value);
125 125
         }
126 126
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     public function find($pattern) {
137 137
         if (preg_match_all($pattern, $this->raw, $matches)) {
138 138
             if (isset($matches[1])) {
139
-                if(count($matches[1]) > 0) {
139
+                if (count($matches[1]) > 0) {
140 140
                     return $matches[1][0];
141 141
                 }
142 142
             }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      *
150 150
      * @throws InvalidMessageDateException
151 151
      */
152
-    protected function parse(){
152
+    protected function parse() {
153 153
         $header = $this->rfc822_parse_headers($this->raw);
154 154
 
155 155
         $this->extractAddresses($header);
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $this->parseDate($header);
168 168
         foreach ($header as $key => $value) {
169 169
             $key = trim(rtrim(strtolower($key)));
170
-            if(!isset($this->attributes[$key])){
170
+            if (!isset($this->attributes[$key])) {
171 171
                 $this->set($key, $value);
172 172
             }
173 173
         }
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
      *
184 184
      * @return object
185 185
      */
186
-    public function rfc822_parse_headers($raw_headers){
186
+    public function rfc822_parse_headers($raw_headers) {
187 187
         $headers = [];
188 188
         $imap_headers = [];
189 189
         if (extension_loaded('imap')) {
190 190
             $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw);
191
-            foreach($raw_imap_headers as $key => $values) {
191
+            foreach ($raw_imap_headers as $key => $values) {
192 192
                 $key = str_replace("-", "_", $key);
193 193
                 $imap_headers[$key] = $values;
194 194
             }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
         $lines = explode("\r\n", $raw_headers);
198 198
         $prev_header = null;
199
-        foreach($lines as $line) {
199
+        foreach ($lines as $line) {
200 200
             if (substr($line, 0, 1) === "\n") {
201 201
                 $line = substr($line, 1);
202 202
             }
@@ -216,19 +216,19 @@  discard block
 block discarded – undo
216 216
                     }
217 217
                     if (is_array($headers[$prev_header])) {
218 218
                         $headers[$prev_header][] = $line;
219
-                    }else{
219
+                    }else {
220 220
                         $headers[$prev_header] .= $line;
221 221
                     }
222 222
                 }
223
-            }else{
223
+            }else {
224 224
                 if (($pos = strpos($line, ":")) > 0) {
225 225
                     $key = trim(rtrim(strtolower(substr($line, 0, $pos))));
226 226
                     $key = str_replace("-", "_", $key);
227 227
 
228 228
                     $value = trim(rtrim(substr($line, $pos + 1)));
229 229
                     if (isset($headers[$key])) {
230
-                        $headers[$key][]  = $value;
231
-                    }else{
230
+                        $headers[$key][] = $value;
231
+                    }else {
232 232
                         $headers[$key] = [$value];
233 233
                     }
234 234
                     $prev_header = $key;
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
             }
237 237
         }
238 238
 
239
-        foreach($headers as $key => $values) {
239
+        foreach ($headers as $key => $values) {
240 240
             if (isset($imap_headers[$key])) continue;
241 241
             $value = null;
242
-            switch($key){
242
+            switch ($key) {
243 243
                 case 'from':
244 244
                 case 'to':
245 245
                 case 'cc':
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                     break;
255 255
                 default:
256 256
                     if (is_array($values)) {
257
-                        foreach($values as $k => $v) {
257
+                        foreach ($values as $k => $v) {
258 258
                             if ($v == "") {
259 259
                                 unset($values[$k]);
260 260
                             }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
                             $value = implode(" ", $values);
267 267
                         } elseif ($available_values > 2) {
268 268
                             $value = array_values($values);
269
-                        } else {
269
+                        }else {
270 270
                             $value = "";
271 271
                         }
272 272
                     }
@@ -286,12 +286,12 @@  discard block
 block discarded – undo
286 286
      * @return array The decoded elements are returned in an array of objects, where each
287 287
      * object has two properties, charset and text.
288 288
      */
289
-    public function mime_header_decode($text){
289
+    public function mime_header_decode($text) {
290 290
         if (extension_loaded('imap')) {
291 291
             return \imap_mime_header_decode($text);
292 292
         }
293 293
         $charset = $this->getEncoding($text);
294
-        return [(object)[
294
+        return [(object) [
295 295
             "charset" => $charset,
296 296
             "text" => $this->convertEncoding($text, $charset)
297 297
         ]];
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         try {
346 346
             if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
347 347
                 return iconv($from, $to, $str);
348
-            } else {
348
+            }else {
349 349
                 if (!$from) {
350 350
                     return mb_convert_encoding($str, $to);
351 351
                 }
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
             if (strstr($from, '-')) {
356 356
                 $from = str_replace('-', '', $from);
357 357
                 return $this->convertEncoding($str, $from, $to);
358
-            } else {
358
+            }else {
359 359
                 return $str;
360 360
             }
361 361
         }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
             }
377 377
         }elseif (property_exists($structure, 'charset')) {
378 378
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
379
-        }elseif (is_string($structure) === true){
379
+        }elseif (is_string($structure) === true) {
380 380
             return mb_detect_encoding($structure);
381 381
         }
382 382
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
         $decoder = $this->config['decoder']['message'];
398 398
 
399 399
         if ($value !== null) {
400
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
400
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
401 401
                 $value = \imap_utf8($value);
402 402
                 if (strpos(strtolower($value), '=?utf-8?') === 0) {
403 403
                     $value = mb_decode_mimeheader($value);
@@ -405,14 +405,14 @@  discard block
 block discarded – undo
405 405
                 if ($this->notDecoded($original_value, $value)) {
406 406
                     $decoded_value = $this->mime_header_decode($value);
407 407
                     if (count($decoded_value) > 0) {
408
-                        if(property_exists($decoded_value[0], "text")) {
408
+                        if (property_exists($decoded_value[0], "text")) {
409 409
                             $value = $decoded_value[0]->text;
410 410
                         }
411 411
                     }
412 412
                 }
413
-            }elseif($decoder === 'iconv') {
413
+            }elseif ($decoder === 'iconv') {
414 414
                 $value = iconv_mime_decode($value);
415
-            }else{
415
+            }else {
416 416
                 $value = mb_decode_mimeheader($value);
417 417
             }
418 418
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
      * @return array
436 436
      */
437 437
     private function decodeArray($values) {
438
-        foreach($values as $key => $value) {
438
+        foreach ($values as $key => $value) {
439 439
             $values[$key] = $this->decode($value);
440 440
         }
441 441
         return $values;
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
      * Try to extract the priority from a given raw header string
446 446
      */
447 447
     private function findPriority() {
448
-        if(($priority = $this->get("x_priority")) === null) return;
449
-        switch((int)"$priority"){
448
+        if (($priority = $this->get("x_priority")) === null) return;
449
+        switch ((int) "$priority") {
450 450
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
451 451
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
452 452
                 break;
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
      */
479 479
     private function decodeAddresses($values) {
480 480
         $addresses = [];
481
-        foreach($values as $address) {
481
+        foreach ($values as $address) {
482 482
             $address = trim(rtrim($address));
483 483
             if (strpos($address, ",") == strlen($address) - 1) {
484 484
                 $address = substr($address, 0, -1);
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
                 '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/',
488 488
                 $address,
489 489
                 $matches
490
-            )){
490
+            )) {
491 491
                 $name = trim(rtrim($matches["name"]));
492 492
                 $email = trim(rtrim($matches["email"]));
493 493
                 list($mailbox, $host) = array_pad(explode("@", $email), 2, null);
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
      * @param object $header
507 507
      */
508 508
     private function extractAddresses($header) {
509
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){
509
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) {
510 510
             if (property_exists($header, $key)) {
511 511
                 $this->set($key, $this->parseAddresses($header->$key));
512 512
             }
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
             }
538 538
             if (!property_exists($address, 'personal')) {
539 539
                 $address->personal = false;
540
-            } else {
540
+            }else {
541 541
                 $personalParts = $this->mime_header_decode($address->personal);
542 542
 
543
-                if(is_array($personalParts)) {
543
+                if (is_array($personalParts)) {
544 544
                     $address->personal = '';
545 545
                     foreach ($personalParts as $p) {
546 546
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -564,19 +564,19 @@  discard block
 block discarded – undo
564 564
     /**
565 565
      * Search and extract potential header extensions
566 566
      */
567
-    private function extractHeaderExtensions(){
567
+    private function extractHeaderExtensions() {
568 568
         foreach ($this->attributes as $key => $value) {
569
-            $value = (string)$value;
569
+            $value = (string) $value;
570 570
             // Only parse strings and don't parse any attributes like the user-agent
571 571
             if (in_array($key, ["user_agent"]) === false) {
572
-                if (($pos = strpos($value, ";")) !== false){
572
+                if (($pos = strpos($value, ";")) !== false) {
573 573
                     $original = substr($value, 0, $pos);
574 574
                     $this->set($key, trim(rtrim($original)), true);
575 575
 
576 576
                     // Get all potential extensions
577 577
                     $extensions = explode(";", substr($value, $pos + 1));
578
-                    foreach($extensions as $extension) {
579
-                        if (($pos = strpos($extension, "=")) !== false){
578
+                    foreach ($extensions as $extension) {
579
+                        if (($pos = strpos($extension, "=")) !== false) {
580 580
                             $key = substr($extension, 0, $pos);
581 581
                             $key = trim(rtrim(strtolower($key)));
582 582
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
             $parsed_date = null;
620 620
             $date = $header->date;
621 621
 
622
-            if(preg_match('/\+0580/', $date)) {
622
+            if (preg_match('/\+0580/', $date)) {
623 623
                 $date = str_replace('+0580', '+0530', $date);
624 624
             }
625 625
 
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
                         $date = trim(array_pop($array));
643 643
                         break;
644 644
                 }
645
-                try{
645
+                try {
646 646
                     $parsed_date = Carbon::parse($date);
647 647
                 } catch (\Exception $_e) {
648 648
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e);
Please login to merge, or discard this patch.