Passed
Pull Request — master (#41)
by
unknown
02:49
created
src/ClientManager.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -68,17 +68,17 @@  discard block
 block discarded – undo
68 68
     public static function get($key, $default = null) {
69 69
         $parts = explode('.', $key);
70 70
         $value = null;
71
-        foreach($parts as $part) {
72
-            if($value === null) {
73
-                if(isset(self::$config[$part])) {
71
+        foreach ($parts as $part) {
72
+            if ($value === null) {
73
+                if (isset(self::$config[$part])) {
74 74
                     $value = self::$config[$part];
75
-                }else{
75
+                }else {
76 76
                     break;
77 77
                 }
78
-            }else{
79
-                if(isset($value[$part])) {
78
+            }else {
79
+                if (isset($value[$part])) {
80 80
                     $value = $value[$part];
81
-                }else{
81
+                }else {
82 82
                     break;
83 83
                 }
84 84
             }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function setConfig($config) {
173 173
 
174
-        if(is_array($config) === false) {
174
+        if (is_array($config) === false) {
175 175
             $config = require $config;
176 176
         }
177 177
 
@@ -181,17 +181,17 @@  discard block
 block discarded – undo
181 181
         $vendor_config = require $path;
182 182
         $config = $this->array_merge_recursive_distinct($vendor_config, $config);
183 183
 
184
-        if(is_array($config)){
185
-            if(isset($config['default'])){
186
-                if(isset($config['accounts']) && $config['default'] != false){
184
+        if (is_array($config)) {
185
+            if (isset($config['default'])) {
186
+                if (isset($config['accounts']) && $config['default'] != false) {
187 187
 
188 188
                     $default_config = $vendor_config['accounts']['default'];
189
-                    if(isset($config['accounts'][$config['default']])){
189
+                    if (isset($config['accounts'][$config['default']])) {
190 190
                         $default_config = array_merge($default_config, $config['accounts'][$config['default']]);
191 191
                     }
192 192
 
193
-                    if(is_array($config['accounts'])){
194
-                        foreach($config['accounts'] as $account_key => $account){
193
+                    if (is_array($config['accounts'])) {
194
+                        foreach ($config['accounts'] as $account_key => $account) {
195 195
                             $config['accounts'][$account_key] = array_merge($default_config, $account);
196 196
                         }
197 197
                     }
@@ -227,24 +227,24 @@  discard block
 block discarded – undo
227 227
         $arrays = func_get_args();
228 228
         $base = array_shift($arrays);
229 229
 
230
-        if(!is_array($base)) $base = empty($base) ? array() : array($base);
230
+        if (!is_array($base)) $base = empty($base) ? array() : array($base);
231 231
 
232
-        foreach($arrays as $append) {
232
+        foreach ($arrays as $append) {
233 233
 
234
-            if(!is_array($append)) $append = array($append);
234
+            if (!is_array($append)) $append = array($append);
235 235
 
236
-            foreach($append as $key => $value) {
236
+            foreach ($append as $key => $value) {
237 237
 
238
-                if(!array_key_exists($key, $base) and !is_numeric($key)) {
238
+                if (!array_key_exists($key, $base) and !is_numeric($key)) {
239 239
                     $base[$key] = $append[$key];
240 240
                     continue;
241 241
                 }
242 242
 
243
-                if(is_array($value) or is_array($base[$key])) {
243
+                if (is_array($value) or is_array($base[$key])) {
244 244
                     $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]);
245
-                } else if(is_numeric($key)) {
246
-                    if(!in_array($value, $base)) $base[] = $value;
247
-                } else {
245
+                }else if (is_numeric($key)) {
246
+                    if (!in_array($value, $base)) $base[] = $value;
247
+                }else {
248 248
                     $base[$key] = $value;
249 249
                 }
250 250
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
             if($value === null) {
73 73
                 if(isset(self::$config[$part])) {
74 74
                     $value = self::$config[$part];
75
-                }else{
75
+                } else{
76 76
                     break;
77 77
                 }
78
-            }else{
78
+            } else{
79 79
                 if(isset($value[$part])) {
80 80
                     $value = $value[$part];
81
-                }else{
81
+                } else{
82 82
                     break;
83 83
                 }
84 84
             }
@@ -227,11 +227,15 @@  discard block
 block discarded – undo
227 227
         $arrays = func_get_args();
228 228
         $base = array_shift($arrays);
229 229
 
230
-        if(!is_array($base)) $base = empty($base) ? array() : array($base);
230
+        if(!is_array($base)) {
231
+            $base = empty($base) ? array() : array($base);
232
+        }
231 233
 
232 234
         foreach($arrays as $append) {
233 235
 
234
-            if(!is_array($append)) $append = array($append);
236
+            if(!is_array($append)) {
237
+                $append = array($append);
238
+            }
235 239
 
236 240
             foreach($append as $key => $value) {
237 241
 
@@ -243,7 +247,9 @@  discard block
 block discarded – undo
243 247
                 if(is_array($value) or is_array($base[$key])) {
244 248
                     $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]);
245 249
                 } else if(is_numeric($key)) {
246
-                    if(!in_array($value, $base)) $base[] = $value;
250
+                    if(!in_array($value, $base)) {
251
+                        $base[] = $value;
252
+                    }
247 253
                 } else {
248 254
                     $base[$key] = $value;
249 255
                 }
Please login to merge, or discard this patch.
examples/message_table.blade.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@
 block discarded – undo
26 26
     </tr>
27 27
     </thead>
28 28
     <tbody>
29
-    <?php if($paginator->count() > 0): ?>
30
-        <?php foreach($paginator as $message): ?>
29
+    <?php if ($paginator->count() > 0): ?>
30
+        <?php foreach ($paginator as $message): ?>
31 31
             <tr>
32 32
                 <td><?php echo $message->getUid(); ?></td>
33 33
                 <td><?php echo $message->getSubject(); ?></td>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,11 +35,14 @@
 block discarded – undo
35 35
                 <td><?php echo $message->getAttachments()->count() > 0 ? 'yes' : 'no'; ?></td>
36 36
             </tr>
37 37
         <?php endforeach; ?>
38
-    <?php else: ?>
38
+    <?php else {
39
+    : ?>
39 40
         <tr>
40 41
             <td colspan="4">No messages found</td>
41 42
         </tr>
42
-    <?php endif; ?>
43
+    <?php endif;
44
+}
45
+?>
43 46
     </tbody>
44 47
 </table>
45 48
 
Please login to merge, or discard this patch.
examples/folder_structure.blade.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@
 block discarded – undo
24 24
     </tr>
25 25
     </thead>
26 26
     <tbody>
27
-    <?php if($paginator->count() > 0): ?>
28
-        <?php foreach($paginator as $folder): ?>
27
+    <?php if ($paginator->count() > 0): ?>
28
+        <?php foreach ($paginator as $folder): ?>
29 29
                 <tr>
30 30
                     <td><?php echo $folder->name; ?></td>
31 31
                     <td><?php echo $folder->search()->unseen()->setFetchBody(false)->count(); ?></td>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,11 +31,14 @@
 block discarded – undo
31 31
                     <td><?php echo $folder->search()->unseen()->setFetchBody(false)->count(); ?></td>
32 32
                 </tr>
33 33
         <?php endforeach; ?>
34
-    <?php else: ?>
34
+    <?php else {
35
+    : ?>
35 36
         <tr>
36 37
             <td colspan="4">No folders found</td>
37 38
         </tr>
38
-    <?php endif; ?>
39
+    <?php endif;
40
+}
41
+?>
39 42
     </tbody>
40 43
 </table>
41 44
 
Please login to merge, or discard this patch.
src/Part.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@
 block discarded – undo
121 121
     protected function parse(){
122 122
         if ($this->header === null) {
123 123
             $body = $this->findHeaders();
124
-        }else{
124
+        } else{
125 125
             $body = $this->raw;
126 126
         }
127 127
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 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,8 +298,8 @@  discard block
 block discarded – undo
298 298
      *
299 299
      * @return bool
300 300
      */
301
-    public function isAttachment(){
302
-        if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition) || !in_array(strtolower($this->disposition), ['attachment', 'inline'])) ) ) {
301
+    public function isAttachment() {
302
+        if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition) || !in_array(strtolower($this->disposition), ['attachment', 'inline'])))) {
303 303
             if (($this->subtype == null || in_array((strtolower($this->subtype)), ["plain", "csv", "html"])) && $this->filename == null && $this->name == null) {
304 304
                 return false;
305 305
             }
Please login to merge, or discard this patch.
src/Client.php 3 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
      * @param array $config
177 177
      * @param array $default_config
178 178
      */
179
-    private function setAccountConfig($key, $config, $default_config){
179
+    private function setAccountConfig($key, $config, $default_config) {
180 180
         $value = $this->default_account_config[$key];
181
-        if(isset($config[$key])) {
181
+        if (isset($config[$key])) {
182 182
             $value = $config[$key];
183
-        }elseif(isset($default_config[$key])) {
183
+        }elseif (isset($default_config[$key])) {
184 184
             $value = $default_config[$key];
185 185
         }
186 186
         $this->$key = $value;
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
      */
193 193
     protected function setEventsFromConfig($config) {
194 194
         $this->events = ClientManager::get("events");
195
-        if(isset($config['events'])){
196
-            if(isset($config['events'])) {
197
-                foreach($config['events'] as $section => $events) {
195
+        if (isset($config['events'])) {
196
+            if (isset($config['events'])) {
197
+                foreach ($config['events'] as $section => $events) {
198 198
                     $this->events[$section] = array_merge($this->events[$section], $events);
199 199
                 }
200 200
             }
@@ -208,45 +208,45 @@  discard block
 block discarded – undo
208 208
      * @throws MaskNotFoundException
209 209
      */
210 210
     protected function setMaskFromConfig($config) {
211
-        $default_config  = ClientManager::get("masks");
211
+        $default_config = ClientManager::get("masks");
212 212
 
213
-        if(isset($config['masks'])){
214
-            if(isset($config['masks']['message'])) {
215
-                if(class_exists($config['masks']['message'])) {
213
+        if (isset($config['masks'])) {
214
+            if (isset($config['masks']['message'])) {
215
+                if (class_exists($config['masks']['message'])) {
216 216
                     $this->default_message_mask = $config['masks']['message'];
217
-                }else{
217
+                }else {
218 218
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
219 219
                 }
220
-            }else{
221
-                if(class_exists($default_config['message'])) {
220
+            }else {
221
+                if (class_exists($default_config['message'])) {
222 222
                     $this->default_message_mask = $default_config['message'];
223
-                }else{
223
+                }else {
224 224
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
225 225
                 }
226 226
             }
227
-            if(isset($config['masks']['attachment'])) {
228
-                if(class_exists($config['masks']['attachment'])) {
227
+            if (isset($config['masks']['attachment'])) {
228
+                if (class_exists($config['masks']['attachment'])) {
229 229
                     $this->default_message_mask = $config['masks']['attachment'];
230
-                }else{
230
+                }else {
231 231
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
232 232
                 }
233
-            }else{
234
-                if(class_exists($default_config['attachment'])) {
233
+            }else {
234
+                if (class_exists($default_config['attachment'])) {
235 235
                     $this->default_message_mask = $default_config['attachment'];
236
-                }else{
236
+                }else {
237 237
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
238 238
                 }
239 239
             }
240
-        }else{
241
-            if(class_exists($default_config['message'])) {
240
+        }else {
241
+            if (class_exists($default_config['message'])) {
242 242
                 $this->default_message_mask = $default_config['message'];
243
-            }else{
243
+            }else {
244 244
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
245 245
             }
246 246
 
247
-            if(class_exists($default_config['attachment'])) {
247
+            if (class_exists($default_config['attachment'])) {
248 248
                 $this->default_message_mask = $default_config['attachment'];
249
-            }else{
249
+            }else {
250 250
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
251 251
             }
252 252
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             $timeout = $this->connection !== false ? $this->connection->getConnectionTimeout() : null;
311 311
             $this->connection = new ImapProtocol($this->validate_cert);
312 312
             $this->connection->setConnectionTimeout($timeout);
313
-        }else{
313
+        }else {
314 314
             if (extension_loaded('imap') === false) {
315 315
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
316 316
             }
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
388 388
         $items = $this->connection->folders('', $pattern);
389 389
 
390
-        if(is_array($items)){
390
+        if (is_array($items)) {
391 391
             foreach ($items as $folder_name => $item) {
392 392
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
393 393
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
             }
403 403
 
404 404
             return $folders;
405
-        }else{
405
+        }else {
406 406
             throw new FolderFetchingException("failed to fetch any folders");
407 407
         }
408 408
     }
@@ -436,10 +436,10 @@  discard block
 block discarded – undo
436 436
     public function createFolder($folder, $expunge = true) {
437 437
         $this->checkConnection();
438 438
         $status = $this->connection->createFolder($folder);
439
-        if($expunge) $this->expunge();
439
+        if ($expunge) $this->expunge();
440 440
 
441 441
         $folder = $this->getFolder($folder);
442
-        if($status && $folder) {
442
+        if ($status && $folder) {
443 443
             $event = $this->getEvent("folder", "new");
444 444
             $event::dispatch($folder);
445 445
         }
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
      *
465 465
      * @return Folder
466 466
      */
467
-    public function getFolderPath(){
467
+    public function getFolderPath() {
468 468
         return $this->active_folder;
469 469
     }
470 470
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
      *
519 519
      * @return int
520 520
      */
521
-    public function getTimeout($type){
521
+    public function getTimeout($type) {
522 522
         return $this->connection->getConnectionTimeout();
523 523
     }
524 524
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
      *
528 528
      * @return string
529 529
      */
530
-    public function getDefaultMessageMask(){
530
+    public function getDefaultMessageMask() {
531 531
         return $this->default_message_mask;
532 532
     }
533 533
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
      *
538 538
      * @return array
539 539
      */
540
-    public function getDefaultEvents($section){
540
+    public function getDefaultEvents($section) {
541 541
         return $this->events[$section];
542 542
     }
543 543
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
      * @throws MaskNotFoundException
550 550
      */
551 551
     public function setDefaultMessageMask($mask) {
552
-        if(class_exists($mask)) {
552
+        if (class_exists($mask)) {
553 553
             $this->default_message_mask = $mask;
554 554
 
555 555
             return $this;
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
      *
564 564
      * @return string
565 565
      */
566
-    public function getDefaultAttachmentMask(){
566
+    public function getDefaultAttachmentMask() {
567 567
         return $this->default_attachment_mask;
568 568
     }
569 569
 
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
      * @throws MaskNotFoundException
576 576
      */
577 577
     public function setDefaultAttachmentMask($mask) {
578
-        if(class_exists($mask)) {
578
+        if (class_exists($mask)) {
579 579
             $this->default_attachment_mask = $mask;
580 580
 
581 581
             return $this;
Please login to merge, or discard this patch.
Braces   +15 added lines, -13 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         $value = $this->default_account_config[$key];
181 181
         if(isset($config[$key])) {
182 182
             $value = $config[$key];
183
-        }elseif(isset($default_config[$key])) {
183
+        } elseif(isset($default_config[$key])) {
184 184
             $value = $default_config[$key];
185 185
         }
186 186
         $this->$key = $value;
@@ -214,39 +214,39 @@  discard block
 block discarded – undo
214 214
             if(isset($config['masks']['message'])) {
215 215
                 if(class_exists($config['masks']['message'])) {
216 216
                     $this->default_message_mask = $config['masks']['message'];
217
-                }else{
217
+                } else{
218 218
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
219 219
                 }
220
-            }else{
220
+            } else{
221 221
                 if(class_exists($default_config['message'])) {
222 222
                     $this->default_message_mask = $default_config['message'];
223
-                }else{
223
+                } else{
224 224
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
225 225
                 }
226 226
             }
227 227
             if(isset($config['masks']['attachment'])) {
228 228
                 if(class_exists($config['masks']['attachment'])) {
229 229
                     $this->default_message_mask = $config['masks']['attachment'];
230
-                }else{
230
+                } else{
231 231
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
232 232
                 }
233
-            }else{
233
+            } else{
234 234
                 if(class_exists($default_config['attachment'])) {
235 235
                     $this->default_message_mask = $default_config['attachment'];
236
-                }else{
236
+                } else{
237 237
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
238 238
                 }
239 239
             }
240
-        }else{
240
+        } else{
241 241
             if(class_exists($default_config['message'])) {
242 242
                 $this->default_message_mask = $default_config['message'];
243
-            }else{
243
+            } else{
244 244
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
245 245
             }
246 246
 
247 247
             if(class_exists($default_config['attachment'])) {
248 248
                 $this->default_message_mask = $default_config['attachment'];
249
-            }else{
249
+            } else{
250 250
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
251 251
             }
252 252
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             $timeout = $this->connection !== false ? $this->connection->getConnectionTimeout() : null;
311 311
             $this->connection = new ImapProtocol($this->validate_cert);
312 312
             $this->connection->setConnectionTimeout($timeout);
313
-        }else{
313
+        } else{
314 314
             if (extension_loaded('imap') === false) {
315 315
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
316 316
             }
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
             }
403 403
 
404 404
             return $folders;
405
-        }else{
405
+        } else{
406 406
             throw new FolderFetchingException("failed to fetch any folders");
407 407
         }
408 408
     }
@@ -436,7 +436,9 @@  discard block
 block discarded – undo
436 436
     public function createFolder($folder, $expunge = true) {
437 437
         $this->checkConnection();
438 438
         $status = $this->connection->createFolder($folder);
439
-        if($expunge) $this->expunge();
439
+        if($expunge) {
440
+            $this->expunge();
441
+        }
440 442
 
441 443
         $folder = $this->getFolder($folder);
442 444
         if($status && $folder) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -376,7 +376,7 @@
 block discarded – undo
376 376
             if (strpos($folder_name, $delimiter) !== false) {
377 377
                 return $this->getFolderByPath($folder_name);
378 378
             }
379
-	}
379
+    }
380 380
 
381 381
         return $this->getFolderByName($folder_name);
382 382
     }
Please login to merge, or discard this patch.
src/Query/Query.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -252,7 +252,7 @@
 block discarded – undo
252 252
      */
253 253
     public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
254 254
         if (
255
-               $page === null
255
+                $page === null
256 256
             && isset($_GET[$page_name])
257 257
             && $_GET[$page_name] > 0
258 258
         ) {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
     public function __construct(Client $client, $charset = 'UTF-8') {
77 77
         $this->setClient($client);
78 78
 
79
-        if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
79
+        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
80 80
 
81 81
         if (ClientManager::get('options.fetch_order') === 'desc') {
82 82
             $this->fetch_order = 'desc';
83
-        } else {
83
+        }else {
84 84
             $this->fetch_order = 'asc';
85 85
         }
86 86
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     /**
95 95
      * Instance boot method for additional functionality
96 96
      */
97
-    protected function boot(){}
97
+    protected function boot() {}
98 98
 
99 99
     /**
100 100
      * Parse a given value
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
      *
103 103
      * @return string
104 104
      */
105
-    protected function parse_value($value){
106
-        switch(true){
105
+    protected function parse_value($value) {
106
+        switch (true) {
107 107
             case $value instanceof \Carbon\Carbon:
108 108
                 $value = $value->format($this->date_format);
109 109
                 break;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @throws MessageSearchValidationException
121 121
      */
122 122
     protected function parse_date($date) {
123
-        if($date instanceof \Carbon\Carbon) return $date;
123
+        if ($date instanceof \Carbon\Carbon) return $date;
124 124
 
125 125
         try {
126 126
             $date = Carbon::parse($date);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      * @return Collection
160 160
      * @throws GetMessagesFailedException
161 161
      */
162
-    protected function search(){
162
+    protected function search() {
163 163
         $this->generate_query();
164 164
 
165 165
         try {
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
                     $available_messages = $available_messages->reverse();
207 207
                 }
208 208
 
209
-                $query =& $this;
209
+                $query = & $this;
210 210
 
211 211
                 $available_messages->forPage($this->page, $this->limit)->each(function($msgno, $msglist) use(&$messages, $options, $query) {
212 212
                     $message = $query->getMessage($msgno, $msglist);
213
-                    switch ($options['message_key']){
213
+                    switch ($options['message_key']) {
214 214
                         case 'number':
215 215
                             $message_key = $message->getMessageNo();
216 216
                             break;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
             return $messages;
230 230
         } catch (\Exception $e) {
231
-            throw new GetMessagesFailedException($e->getMessage(),0, $e);
231
+            throw new GetMessagesFailedException($e->getMessage(), 0, $e);
232 232
         }
233 233
     }
234 234
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      * @throws MessageHeaderFetchingException
246 246
      * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
247 247
      */
248
-    public function getMessage($msgno, $msglist = null){
248
+    public function getMessage($msgno, $msglist = null) {
249 249
         return new Message($msgno, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags());
250 250
     }
251 251
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      * @return LengthAwarePaginator
259 259
      * @throws GetMessagesFailedException
260 260
      */
261
-    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
261
+    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') {
262 262
         if (
263 263
                $page === null
264 264
             && isset($_GET[$page_name])
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
         $this->query->each(function($statement) use(&$query) {
285 285
             if (count($statement) == 1) {
286 286
                 $query .= $statement[0];
287
-            } else {
288
-                if($statement[1] === null){
287
+            }else {
288
+                if ($statement[1] === null) {
289 289
                     $query .= $statement[0];
290
-                }else{
290
+                }else {
291 291
                     $query .= $statement[0].' "'.$statement[1].'"';
292 292
                 }
293 293
             }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
      * @return $this
318 318
      */
319 319
     public function limit($limit, $page = 1) {
320
-        if($page >= 1) $this->page = $page;
320
+        if ($page >= 1) $this->page = $page;
321 321
         $this->limit = $limit;
322 322
 
323 323
         return $this;
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -76,7 +76,9 @@  discard block
 block discarded – undo
76 76
     public function __construct(Client $client, $charset = 'UTF-8') {
77 77
         $this->setClient($client);
78 78
 
79
-        if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
79
+        if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) {
80
+            $this->leaveUnread();
81
+        }
80 82
 
81 83
         if (ClientManager::get('options.fetch_order') === 'desc') {
82 84
             $this->fetch_order = 'desc';
@@ -120,7 +122,9 @@  discard block
 block discarded – undo
120 122
      * @throws MessageSearchValidationException
121 123
      */
122 124
     protected function parse_date($date) {
123
-        if($date instanceof \Carbon\Carbon) return $date;
125
+        if($date instanceof \Carbon\Carbon) {
126
+            return $date;
127
+        }
124 128
 
125 129
         try {
126 130
             $date = Carbon::parse($date);
@@ -287,7 +291,7 @@  discard block
 block discarded – undo
287 291
             } else {
288 292
                 if($statement[1] === null){
289 293
                     $query .= $statement[0];
290
-                }else{
294
+                } else{
291 295
                     $query .= $statement[0].' "'.$statement[1].'"';
292 296
                 }
293 297
             }
@@ -317,7 +321,9 @@  discard block
 block discarded – undo
317 321
      * @return $this
318 322
      */
319 323
     public function limit($limit, $page = 1) {
320
-        if($page >= 1) $this->page = $page;
324
+        if($page >= 1) {
325
+            $this->page = $page;
326
+        }
321 327
         $this->limit = $limit;
322 328
 
323 329
         return $this;
Please login to merge, or discard this patch.
src/Attachment.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         $this->part_number = $part->part_number;
105 105
 
106 106
         $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask();
107
-        if($default_mask != null) {
107
+        if ($default_mask != null) {
108 108
             $this->mask = $default_mask;
109 109
         }
110 110
 
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
      * @throws MethodNotFoundException
122 122
      */
123 123
     public function __call($method, $arguments) {
124
-        if(strtolower(substr($method, 0, 3)) === 'get') {
124
+        if (strtolower(substr($method, 0, 3)) === 'get') {
125 125
             $name = Str::snake(substr($method, 3));
126 126
 
127
-            if(isset($this->attributes[$name])) {
127
+            if (isset($this->attributes[$name])) {
128 128
                 return $this->attributes[$name];
129 129
             }
130 130
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      * @return mixed|null
161 161
      */
162 162
     public function __get($name) {
163
-        if(isset($this->attributes[$name])) {
163
+        if (isset($this->attributes[$name])) {
164 164
             return $this->attributes[$name];
165 165
         }
166 166
 
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
             $this->setName($name);
224 224
         }elseif (($filename = $this->part->filename) !== null) {
225 225
             $this->setName($filename);
226
-        } else {
226
+        }else {
227 227
             $this->setName("undefined");
228 228
         }
229 229
 
230 230
         if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) {
231 231
             if ($this->part->ifdescription) {
232 232
                 $this->setName($this->part->description);
233
-            } else {
233
+            }else {
234 234
                 $this->setName($this->part->subtype);
235 235
             }
236 236
         }
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
     public function setName($name) {
257 257
         $decoder = $this->config['decoder']['attachment'];
258 258
         if ($name !== null) {
259
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
259
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
260 260
                 $this->name = \imap_utf8($name);
261
-            }else{
261
+            }else {
262 262
                 $this->name = mb_decode_mimeheader($name);
263 263
             }
264 264
         }
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      *
270 270
      * @return string|null
271 271
      */
272
-    public function getMimeType(){
272
+    public function getMimeType() {
273 273
         return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE);
274 274
     }
275 275
 
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
      *
279 279
      * @return string|null
280 280
      */
281
-    public function getExtension(){
281
+    public function getExtension() {
282 282
         $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser";
283
-        if (class_exists($deprecated_guesser) !== false){
283
+        if (class_exists($deprecated_guesser) !== false) {
284 284
             return $deprecated_guesser::getInstance()->guess($this->getMimeType());
285 285
         }
286 286
         $guesser = "\Symfony\Component\Mime\MimeTypes";
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
      *
294 294
      * @return array
295 295
      */
296
-    public function getAttributes(){
296
+    public function getAttributes() {
297 297
         return $this->attributes;
298 298
     }
299 299
 
300 300
     /**
301 301
      * @return Message
302 302
      */
303
-    public function getMessage(){
303
+    public function getMessage() {
304 304
         return $this->oMessage;
305 305
     }
306 306
 
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
      *
311 311
      * @return $this
312 312
      */
313
-    public function setMask($mask){
314
-        if(class_exists($mask)){
313
+    public function setMask($mask) {
314
+        if (class_exists($mask)) {
315 315
             $this->mask = $mask;
316 316
         }
317 317
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
      *
324 324
      * @return string
325 325
      */
326
-    public function getMask(){
326
+    public function getMask() {
327 327
         return $this->mask;
328 328
     }
329 329
 
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
      * @return mixed
335 335
      * @throws MaskNotFoundException
336 336
      */
337
-    public function mask($mask = null){
337
+    public function mask($mask = null) {
338 338
         $mask = $mask !== null ? $mask : $this->mask;
339
-        if(class_exists($mask)){
339
+        if (class_exists($mask)) {
340 340
             return new $mask($this);
341 341
         }
342 342
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
             }
130 130
 
131 131
             return null;
132
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
132
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
133 133
             $name = Str::snake(substr($method, 3));
134 134
 
135 135
             $this->attributes[$name] = array_pop($arguments);
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 
222 222
         if (($name = $this->part->name) !== null) {
223 223
             $this->setName($name);
224
-        }elseif (($filename = $this->part->filename) !== null) {
224
+        } elseif (($filename = $this->part->filename) !== null) {
225 225
             $this->setName($filename);
226 226
         } else {
227 227
             $this->setName("undefined");
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         if ($name !== null) {
259 259
             if($decoder === 'utf-8' && extension_loaded('imap')) {
260 260
                 $this->name = \imap_utf8($name);
261
-            }else{
261
+            } else{
262 262
                 $this->name = mb_decode_mimeheader($name);
263 263
             }
264 264
         }
Please login to merge, or discard this patch.
src/Structure.php 2 patches
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\=\"?(.*)\"?/");
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.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type;
92 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
     }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                     foreach($match[1] as $matched){
127 127
                         $boundaries[] = str_replace('"', '', $matched);
128 128
                     }
129
-                }else{
129
+                } else{
130 130
                     if(!empty($match[1])) {
131 131
                         $boundaries[] = str_replace('"', '', $match[1]);
132 132
                     }
Please login to merge, or discard this patch.
src/Connection/Protocols/ImapProtocol.php 2 patches
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      * @throws ConnectionFailedException
83 83
      * @throws RuntimeException
84 84
      */
85
-    protected function enableTls(){
85
+    protected function enableTls() {
86 86
         $response = $this->requestAndResponse('STARTTLS');
87 87
         $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod());
88 88
         if (!$result) {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         $stack = [];
145 145
 
146 146
         //  replace any trailing <NL> including spaces with a single space
147
-        $line = rtrim($line) . ' ';
147
+        $line = rtrim($line).' ';
148 148
         while (($pos = strpos($line, ' ')) !== false) {
149 149
             $token = substr($line, 0, $pos);
150 150
             if (!strlen($token)) {
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
                     if (strlen($token) > $chars) {
175 175
                         $line = substr($token, $chars);
176 176
                         $token = substr($token, 0, $chars);
177
-                    } else {
177
+                    }else {
178 178
                         $line .= $this->nextLine();
179 179
                     }
180 180
                     $tokens[] = $token;
181
-                    $line = trim($line) . ' ';
181
+                    $line = trim($line).' ';
182 182
                     continue;
183 183
                 }
184 184
             }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         $line = $this->nextTaggedLine($tag); // get next tag
229 229
         if (!$dontParse) {
230 230
             $tokens = $this->decodeLine($line);
231
-        } else {
231
+        }else {
232 232
             $tokens = $line;
233 233
         }
234 234
 
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
             // First two chars are still needed for the response code
256 256
             $tokens = [substr($tokens, 0, 2)];
257 257
         }
258
-        if (is_array($lines)){
258
+        if (is_array($lines)) {
259 259
             if ($this->debug) echo "<< ".json_encode($lines)."\n";
260
-        }else{
260
+        }else {
261 261
             if ($this->debug) echo "<< ".$lines."\n";
262 262
         }
263 263
 
@@ -282,27 +282,27 @@  discard block
 block discarded – undo
282 282
     public function sendRequest($command, $tokens = [], &$tag = null) {
283 283
         if (!$tag) {
284 284
             $this->noun++;
285
-            $tag = 'TAG' . $this->noun;
285
+            $tag = 'TAG'.$this->noun;
286 286
         }
287 287
 
288
-        $line = $tag . ' ' . $command;
288
+        $line = $tag.' '.$command;
289 289
 
290 290
         foreach ($tokens as $token) {
291 291
             if (is_array($token)) {
292
-                if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) {
292
+                if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) {
293 293
                     throw new RuntimeException('failed to write - connection closed?');
294 294
                 }
295 295
                 if (!$this->assumedNextLine('+ ')) {
296 296
                     throw new RuntimeException('failed to send literal string');
297 297
                 }
298 298
                 $line = $token[1];
299
-            } else {
300
-                $line .= ' ' . $token;
299
+            }else {
300
+                $line .= ' '.$token;
301 301
             }
302 302
         }
303 303
         if ($this->debug) echo ">> ".$line."\n";
304 304
 
305
-        if (fwrite($this->stream, $line . "\r\n") === false) {
305
+        if (fwrite($this->stream, $line."\r\n") === false) {
306 306
             throw new RuntimeException('failed to write - connection closed?');
307 307
         }
308 308
     }
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
     public function escapeString($string) {
333 333
         if (func_num_args() < 2) {
334 334
             if (strpos($string, "\n") !== false) {
335
-                return ['{' . strlen($string) . '}', $string];
336
-            } else {
337
-                return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
335
+                return ['{'.strlen($string).'}', $string];
336
+            }else {
337
+                return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"';
338 338
             }
339 339
         }
340 340
         $result = [];
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             }
360 360
             $result[] = $this->escapeList($v);
361 361
         }
362
-        return '(' . implode(' ', $result) . ')';
362
+        return '('.implode(' ', $result).')';
363 363
     }
364 364
 
365 365
     /**
@@ -399,12 +399,12 @@  discard block
 block discarded – undo
399 399
                     error_log("got an extra server challenge: $response");
400 400
                     // respond with an empty response.
401 401
                     $this->sendRequest('');
402
-                } else {
402
+                }else {
403 403
                     if (preg_match('/^NO /i', $response) ||
404 404
                         preg_match('/^BAD /i', $response)) {
405 405
                         error_log("got failure response: $response");
406 406
                         return false;
407
-                    } else if (preg_match("/^OK /i", $response)) {
407
+                    }else if (preg_match("/^OK /i", $response)) {
408 408
                         return true;
409 409
                     }
410 410
                 }
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
      *
438 438
      * @return bool
439 439
      */
440
-    public function connected(){
440
+    public function connected() {
441 441
         return (boolean) $this->stream;
442 442
     }
443 443
 
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
                     $result[strtolower($tokens[1])] = $tokens[0];
485 485
                     break;
486 486
                 case '[UIDVALIDITY':
487
-                    $result['uidvalidity'] = (int)$tokens[2];
487
+                    $result['uidvalidity'] = (int) $tokens[2];
488 488
                     break;
489 489
                 case '[UIDNEXT':
490
-                    $result['uidnext'] = (int)$tokens[2];
490
+                    $result['uidnext'] = (int) $tokens[2];
491 491
                     break;
492 492
                 default:
493 493
                     // ignore
@@ -541,17 +541,17 @@  discard block
 block discarded – undo
541 541
         if (is_array($from)) {
542 542
             $set = implode(',', $from);
543 543
         } elseif ($to === null) {
544
-            $set = (int)$from;
544
+            $set = (int) $from;
545 545
         } elseif ($to === INF) {
546
-            $set = (int)$from . ':*';
547
-        } else {
548
-            $set = (int)$from . ':' . (int)$to;
546
+            $set = (int) $from.':*';
547
+        }else {
548
+            $set = (int) $from.':'.(int) $to;
549 549
         }
550 550
 
551
-        $items = (array)$items;
551
+        $items = (array) $items;
552 552
         $itemList = $this->escapeList($items);
553 553
 
554
-        $this->sendRequest(($uid ? 'UID ' : '') . 'FETCH', [$set, $itemList], $tag);
554
+        $this->sendRequest(($uid ? 'UID ' : '').'FETCH', [$set, $itemList], $tag);
555 555
 
556 556
         $result = [];
557 557
         $tokens = null; // define $tokens variable before first use
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
                 $count = count($tokens[2]);
567 567
                 if ($tokens[2][$count - 2] == 'UID') {
568 568
                     $uidKey = $count - 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]);
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
      * @return array
640 640
      * @throws RuntimeException
641 641
      */
642
-    public function headers($uids, $rfc = "RFC822"){
642
+    public function headers($uids, $rfc = "RFC822") {
643 643
         return $this->fetch(["$rfc.HEADER"], $uids);
644 644
     }
645 645
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
      * @return array
651 651
      * @throws RuntimeException
652 652
      */
653
-    public function flags($uids){
653
+    public function flags($uids) {
654 654
         return $this->fetch(["FLAGS"], $uids);
655 655
     }
656 656
 
@@ -734,22 +734,22 @@  discard block
 block discarded – undo
734 734
     public function store(array $flags, $from, $to = null, $mode = null, $silent = true) {
735 735
         $item = 'FLAGS';
736 736
         if ($mode == '+' || $mode == '-') {
737
-            $item = $mode . $item;
737
+            $item = $mode.$item;
738 738
         }
739 739
         if ($silent) {
740 740
             $item .= '.SILENT';
741 741
         }
742 742
 
743 743
         $flags = $this->escapeList($flags);
744
-        $set = (int)$from;
744
+        $set = (int) $from;
745 745
         if ($to !== null) {
746
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
746
+            $set .= ':'.($to == INF ? '*' : (int) $to);
747 747
         }
748 748
 
749 749
         $result = $this->requestAndResponse('STORE', [$set, $item, $flags], $silent);
750 750
 
751 751
         if ($silent) {
752
-            return (bool)$result;
752
+            return (bool) $result;
753 753
         }
754 754
 
755 755
         $tokens = $result;
@@ -799,9 +799,9 @@  discard block
 block discarded – undo
799 799
      * @throws RuntimeException
800 800
      */
801 801
     public function copyMessage($folder, $from, $to = null) {
802
-        $set = (int)$from;
802
+        $set = (int) $from;
803 803
         if ($to !== null) {
804
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
804
+            $set .= ':'.($to == INF ? '*' : (int) $to);
805 805
         }
806 806
 
807 807
         return $this->requestAndResponse('COPY', [$set, $this->escapeString($folder)], true);
@@ -818,9 +818,9 @@  discard block
 block discarded – undo
818 818
      * @throws RuntimeException
819 819
      */
820 820
     public function moveMessage($folder, $from, $to = null) {
821
-        $set = (int)$from;
821
+        $set = (int) $from;
822 822
         if ($to !== null) {
823
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
823
+            $set .= ':'.($to == INF ? '*' : (int) $to);
824 824
         }
825 825
 
826 826
         return $this->requestAndResponse('MOVE', [$set, $this->escapeString($folder)], true);
@@ -971,14 +971,14 @@  discard block
 block discarded – undo
971 971
     /**
972 972
      * Enable the debug mode
973 973
      */
974
-    public function enableDebug(){
974
+    public function enableDebug() {
975 975
         $this->debug = true;
976 976
     }
977 977
 
978 978
     /**
979 979
      * Disable the debug mode
980 980
      */
981
-    public function disableDebug(){
981
+    public function disableDebug() {
982 982
         $this->debug = false;
983 983
     }
984 984
 }
985 985
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -256,9 +256,13 @@  discard block
 block discarded – undo
256 256
             $tokens = [substr($tokens, 0, 2)];
257 257
         }
258 258
         if (is_array($lines)){
259
-            if ($this->debug) echo "<< ".json_encode($lines)."\n";
260
-        }else{
261
-            if ($this->debug) echo "<< ".$lines."\n";
259
+            if ($this->debug) {
260
+                echo "<< ".json_encode($lines)."\n";
261
+            }
262
+        } else{
263
+            if ($this->debug) {
264
+                echo "<< ".$lines."\n";
265
+            }
262 266
         }
263 267
 
264 268
         // last line has response code
@@ -300,7 +304,9 @@  discard block
 block discarded – undo
300 304
                 $line .= ' ' . $token;
301 305
             }
302 306
         }
303
-        if ($this->debug) echo ">> ".$line."\n";
307
+        if ($this->debug) {
308
+            echo ">> ".$line."\n";
309
+        }
304 310
 
305 311
         if (fwrite($this->stream, $line . "\r\n") === false) {
306 312
             throw new RuntimeException('failed to write - connection closed?');
@@ -450,7 +456,9 @@  discard block
 block discarded – undo
450 456
     public function getCapabilities() {
451 457
         $response = $this->requestAndResponse('CAPABILITY');
452 458
 
453
-        if (!$response) return [];
459
+        if (!$response) {
460
+            return [];
461
+        }
454 462
 
455 463
         $capabilities = [];
456 464
         foreach ($response as $line) {
@@ -605,9 +613,10 @@  discard block
 block discarded – undo
605 613
             // if we want only one message we can ignore everything else and just return
606 614
             if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) {
607 615
                 // we still need to read all lines
608
-                while (!$this->readLine($tokens, $tag))
609
-
616
+                while (!$this->readLine($tokens, $tag)) {
617
+                
610 618
                     return $data;
619
+                }
611 620
             }
612 621
             $result[$tokens[0]] = $data;
613 622
         }
Please login to merge, or discard this patch.