Passed
Push — master ( daa768...1c2115 )
by Malte
02:37
created
src/Folder.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
         $this->setDelimiter($delimiter);
124 124
         $this->path      = $folder_name;
125
-        $this->full_name  = $this->decodeName($folder_name);
125
+        $this->full_name = $this->decodeName($folder_name);
126 126
         $this->name      = $this->getSimpleName($this->delimiter, $this->full_name);
127 127
 
128 128
         $this->parseAttributes($attributes);
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      * @throws Exceptions\ConnectionFailedException
137 137
      * @throws Exceptions\RuntimeException
138 138
      */
139
-    public function query($charset = 'UTF-8'){
139
+    public function query($charset = 'UTF-8') {
140 140
         $this->getClient()->checkConnection();
141 141
         $this->getClient()->openFolder($this->path);
142 142
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      * @throws Exceptions\ConnectionFailedException
149 149
      * @throws Exceptions\RuntimeException
150 150
      */
151
-    public function search($charset = 'UTF-8'){
151
+    public function search($charset = 'UTF-8') {
152 152
         return $this->query($charset);
153 153
     }
154 154
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      * @throws Exceptions\ConnectionFailedException
158 158
      * @throws Exceptions\RuntimeException
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");
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      * @throws Exceptions\InvalidMessageDateException
251 251
      * @throws Exceptions\RuntimeException
252 252
      */
253
-    public function overview($sequence = null){
253
+    public function overview($sequence = null) {
254 254
         $this->client->openFolder($this->path);
255 255
         $sequence = $sequence === null ? "1:*" : $sequence;
256 256
         $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID;
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
          */
276 276
 
277 277
         if ($internal_date != null) {
278
-            if ($internal_date instanceof Carbon){
278
+            if ($internal_date instanceof Carbon) {
279 279
                 $internal_date = $internal_date->format('d-M-Y H:i:s O');
280 280
             }
281 281
         }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
      */
310 310
     public function delete($expunge = true) {
311 311
         $status = $this->client->getConnection()->deleteFolder($this->path);
312
-        if($expunge) $this->client->expunge();
312
+        if ($expunge) $this->client->expunge();
313 313
 
314 314
         $event = $this->getEvent("folder", "deleted");
315 315
         $event::dispatch($this);
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
             try {
370 370
                 $line = $connection->nextLine();
371 371
                 if (($pos = strpos($line, "EXISTS")) !== false) {
372
-                    $msgn = (int) substr($line, 2, $pos -2);
372
+                    $msgn = (int) substr($line, 2, $pos - 2);
373 373
                     $connection->done();
374 374
 
375 375
                     $this->client->openFolder($this->path, true);
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 
383 383
                     $connection->idle();
384 384
                 }
385
-            }catch (Exceptions\RuntimeException $e) {
386
-                if(strpos($e->getMessage(), "connection closed") === false) {
385
+            } catch (Exceptions\RuntimeException $e) {
386
+                if (strpos($e->getMessage(), "connection closed") === false) {
387 387
                     throw $e;
388 388
                 }
389 389
                 if ($auto_reconnect === true) {
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
      * Set the delimiter
429 429
      * @param $delimiter
430 430
      */
431
-    public function setDelimiter($delimiter){
432
-        if(in_array($delimiter, [null, '', ' ', false]) === true) {
431
+    public function setDelimiter($delimiter) {
432
+        if (in_array($delimiter, [null, '', ' ', false]) === true) {
433 433
             $delimiter = ClientManager::get('options.delimiter', '/');
434 434
         }
435 435
 
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
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
      * @param array $config
204 204
      * @param array $default_config
205 205
      */
206
-    private function setAccountConfig($key, $config, $default_config){
206
+    private function setAccountConfig($key, $config, $default_config) {
207 207
         $value = $this->default_account_config[$key];
208
-        if(isset($config[$key])) {
208
+        if (isset($config[$key])) {
209 209
             $value = $config[$key];
210
-        }elseif(isset($default_config[$key])) {
210
+        }elseif (isset($default_config[$key])) {
211 211
             $value = $default_config[$key];
212 212
         }
213 213
         $this->$key = $value;
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
      */
220 220
     protected function setEventsFromConfig($config) {
221 221
         $this->events = ClientManager::get("events");
222
-        if(isset($config['events'])){
223
-            if(isset($config['events'])) {
224
-                foreach($config['events'] as $section => $events) {
222
+        if (isset($config['events'])) {
223
+            if (isset($config['events'])) {
224
+                foreach ($config['events'] as $section => $events) {
225 225
                     $this->events[$section] = array_merge($this->events[$section], $events);
226 226
                 }
227 227
             }
@@ -235,45 +235,45 @@  discard block
 block discarded – undo
235 235
      * @throws MaskNotFoundException
236 236
      */
237 237
     protected function setMaskFromConfig($config) {
238
-        $default_config  = ClientManager::get("masks");
238
+        $default_config = ClientManager::get("masks");
239 239
 
240
-        if(isset($config['masks'])){
241
-            if(isset($config['masks']['message'])) {
242
-                if(class_exists($config['masks']['message'])) {
240
+        if (isset($config['masks'])) {
241
+            if (isset($config['masks']['message'])) {
242
+                if (class_exists($config['masks']['message'])) {
243 243
                     $this->default_message_mask = $config['masks']['message'];
244
-                }else{
244
+                }else {
245 245
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
246 246
                 }
247
-            }else{
248
-                if(class_exists($default_config['message'])) {
247
+            }else {
248
+                if (class_exists($default_config['message'])) {
249 249
                     $this->default_message_mask = $default_config['message'];
250
-                }else{
250
+                }else {
251 251
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
252 252
                 }
253 253
             }
254
-            if(isset($config['masks']['attachment'])) {
255
-                if(class_exists($config['masks']['attachment'])) {
254
+            if (isset($config['masks']['attachment'])) {
255
+                if (class_exists($config['masks']['attachment'])) {
256 256
                     $this->default_message_mask = $config['masks']['attachment'];
257
-                }else{
257
+                }else {
258 258
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
259 259
                 }
260
-            }else{
261
-                if(class_exists($default_config['attachment'])) {
260
+            }else {
261
+                if (class_exists($default_config['attachment'])) {
262 262
                     $this->default_message_mask = $default_config['attachment'];
263
-                }else{
263
+                }else {
264 264
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
265 265
                 }
266 266
             }
267
-        }else{
268
-            if(class_exists($default_config['message'])) {
267
+        }else {
268
+            if (class_exists($default_config['message'])) {
269 269
                 $this->default_message_mask = $default_config['message'];
270
-            }else{
270
+            }else {
271 271
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
272 272
             }
273 273
 
274
-            if(class_exists($default_config['attachment'])) {
274
+            if (class_exists($default_config['attachment'])) {
275 275
                 $this->default_message_mask = $default_config['attachment'];
276
-            }else{
276
+            }else {
277 277
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
278 278
             }
279 279
         }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
338 338
             $this->connection->setConnectionTimeout($this->timeout);
339 339
             $this->connection->setProxy($this->proxy);
340
-        }else{
340
+        }else {
341 341
             if (extension_loaded('imap') === false) {
342 342
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
343 343
             }
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
461 461
         $items = $this->connection->folders('', $pattern);
462 462
 
463
-        if(is_array($items)){
463
+        if (is_array($items)) {
464 464
             foreach ($items as $folder_name => $item) {
465 465
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
466 466
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
             }
476 476
 
477 477
             return $folders;
478
-        }else{
478
+        }else {
479 479
             throw new FolderFetchingException("failed to fetch any folders");
480 480
         }
481 481
     }
@@ -513,10 +513,10 @@  discard block
 block discarded – undo
513 513
         $this->checkConnection();
514 514
         $status = $this->connection->createFolder($folder);
515 515
 
516
-        if($expunge) $this->expunge();
516
+        if ($expunge) $this->expunge();
517 517
 
518 518
         $folder = $this->getFolder($folder);
519
-        if($status && $folder) {
519
+        if ($status && $folder) {
520 520
             $event = $this->getEvent("folder", "new");
521 521
             $event::dispatch($folder);
522 522
         }
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
      *
543 543
      * @return Folder
544 544
      */
545
-    public function getFolderPath(){
545
+    public function getFolderPath() {
546 546
         return $this->active_folder;
547 547
     }
548 548
 
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
      *
598 598
      * @return int
599 599
      */
600
-    public function getTimeout(){
600
+    public function getTimeout() {
601 601
         return $this->connection->getConnectionTimeout();
602 602
     }
603 603
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      *
607 607
      * @return string
608 608
      */
609
-    public function getDefaultMessageMask(){
609
+    public function getDefaultMessageMask() {
610 610
         return $this->default_message_mask;
611 611
     }
612 612
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
      *
617 617
      * @return array
618 618
      */
619
-    public function getDefaultEvents($section){
619
+    public function getDefaultEvents($section) {
620 620
         return $this->events[$section];
621 621
     }
622 622
 
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
      * @throws MaskNotFoundException
629 629
      */
630 630
     public function setDefaultMessageMask($mask) {
631
-        if(class_exists($mask)) {
631
+        if (class_exists($mask)) {
632 632
             $this->default_message_mask = $mask;
633 633
 
634 634
             return $this;
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
      *
643 643
      * @return string
644 644
      */
645
-    public function getDefaultAttachmentMask(){
645
+    public function getDefaultAttachmentMask() {
646 646
         return $this->default_attachment_mask;
647 647
     }
648 648
 
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
      * @throws MaskNotFoundException
655 655
      */
656 656
     public function setDefaultAttachmentMask($mask) {
657
-        if(class_exists($mask)) {
657
+        if (class_exists($mask)) {
658 658
             $this->default_attachment_mask = $mask;
659 659
 
660 660
             return $this;
Please login to merge, or discard this patch.
src/Query/Query.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 
89 89
         if (ClientManager::get('options.fetch_order') === 'desc') {
90 90
             $this->fetch_order = 'desc';
91
-        } else {
91
+        }else {
92 92
             $this->fetch_order = 'asc';
93 93
         }
94 94
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                 break;
119 119
         }
120 120
 
121
-        return (string)$value;
121
+        return (string) $value;
122 122
     }
123 123
 
124 124
     /**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                     $raw_flag = isset($raw_flags[$uid]) ? $raw_flags[$uid] : [];
246 246
 
247 247
                     $message = Message::make($uid, $msglist, $this->getClient(), $raw_header, $raw_content, $raw_flag, $this->getFetchOptions(), $this->sequence);
248
-                    switch ($message_key){
248
+                    switch ($message_key) {
249 249
                         case 'number':
250 250
                             $key = $message->getMessageNo();
251 251
                             break;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
             return $messages;
269 269
         } catch (\Exception $e) {
270
-            throw new GetMessagesFailedException($e->getMessage(),0, $e);
270
+            throw new GetMessagesFailedException($e->getMessage(), 0, $e);
271 271
         }
272 272
     }
273 273
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
      * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
287 287
      * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException
288 288
      */
289
-    public function getMessage($uid, $msglist = null, $sequence = null){
289
+    public function getMessage($uid, $msglist = null, $sequence = null) {
290 290
         return new Message($uid, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags(), $sequence ? $sequence : $this->sequence);
291 291
     }
292 292
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
305 305
      * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException
306 306
      */
307
-    public function getMessageByMsgn($msgn, $msglist = null){
307
+    public function getMessageByMsgn($msgn, $msglist = null) {
308 308
         return $this->getMessage($msgn, $msglist, IMAP::ST_MSGN);
309 309
     }
310 310
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
322 322
      * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException
323 323
      */
324
-    public function getMessageByUid($uid){
324
+    public function getMessageByUid($uid) {
325 325
         return $this->getMessage($uid, null, IMAP::ST_UID);
326 326
     }
327 327
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      * @return LengthAwarePaginator
335 335
      * @throws GetMessagesFailedException
336 336
      */
337
-    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
337
+    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') {
338 338
         if (
339 339
                $page === null
340 340
             && isset($_GET[$page_name])
@@ -360,10 +360,10 @@  discard block
 block discarded – undo
360 360
         $this->query->each(function($statement) use(&$query) {
361 361
             if (count($statement) == 1) {
362 362
                 $query .= $statement[0];
363
-            } else {
364
-                if($statement[1] === null){
363
+            }else {
364
+                if ($statement[1] === null) {
365 365
                     $query .= $statement[0];
366
-                }else{
366
+                }else {
367 367
                     $query .= $statement[0].' "'.$statement[1].'"';
368 368
                 }
369 369
             }
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -84,7 +84,9 @@  discard block
 block discarded – undo
84 84
         $this->setClient($client);
85 85
 
86 86
         $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN);
87
-        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
87
+        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) {
88
+            $this->leaveUnread();
89
+        }
88 90
 
89 91
         if (ClientManager::get('options.fetch_order') === 'desc') {
90 92
             $this->fetch_order = 'desc';
@@ -129,7 +131,9 @@  discard block
 block discarded – undo
129 131
      * @throws MessageSearchValidationException
130 132
      */
131 133
     protected function parse_date($date) {
132
-        if ($date instanceof Carbon) return $date;
134
+        if ($date instanceof Carbon) {
135
+            return $date;
136
+        }
133 137
 
134 138
         try {
135 139
             $date = Carbon::parse($date);
@@ -363,7 +367,7 @@  discard block
 block discarded – undo
363 367
             } else {
364 368
                 if($statement[1] === null){
365 369
                     $query .= $statement[0];
366
-                }else{
370
+                } else{
367 371
                     $query .= $statement[0].' "'.$statement[1].'"';
368 372
                 }
369 373
             }
@@ -393,7 +397,9 @@  discard block
 block discarded – undo
393 397
      * @return $this
394 398
      */
395 399
     public function limit($limit, $page = 1) {
396
-        if ($page >= 1) $this->page = $page;
400
+        if ($page >= 1) {
401
+            $this->page = $page;
402
+        }
397 403
         $this->limit = $limit;
398 404
 
399 405
         return $this;
Please login to merge, or discard this patch.
src/Query/WhereQuery.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
         }
86 86
 
87 87
         if (strpos(strtolower($name), "where") === false) {
88
-            $method = 'where' . ucfirst($name);
89
-        } else {
88
+            $method = 'where'.ucfirst($name);
89
+        }else {
90 90
             $method = lcfirst($name);
91 91
         }
92 92
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
             return call_user_func_array([$that, $method], $arguments);
95 95
         }
96 96
 
97
-        throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported');
97
+        throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported');
98 98
     }
99 99
 
100 100
     /**
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
                 }
132 132
                 return $this->where($key, $value);
133 133
             }
134
-        } else {
134
+        }else {
135 135
             $criteria = $this->validate_criteria($criteria);
136 136
             $value = $this->parse_value($value);
137 137
 
138 138
             if ($value === null || $value === '') {
139 139
                 $this->query->push([$criteria]);
140
-            } else {
140
+            }else {
141 141
                 $this->query->push([$criteria, $value]);
142 142
             }
143 143
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -152,7 +152,9 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function orWhere(Closure $closure = null) {
154 154
         $this->query->push(['OR']);
155
-        if ($closure !== null) $closure($this);
155
+        if ($closure !== null) {
156
+            $closure($this);
157
+        }
156 158
 
157 159
         return $this;
158 160
     }
@@ -164,7 +166,9 @@  discard block
 block discarded – undo
164 166
      */
165 167
     public function andWhere(Closure $closure = null) {
166 168
         $this->query->push(['AND']);
167
-        if ($closure !== null) $closure($this);
169
+        if ($closure !== null) {
170
+            $closure($this);
171
+        }
168 172
 
169 173
         return $this;
170 174
     }
Please login to merge, or discard this patch.
src/Message.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false, $sequence = null) {
205 205
 
206 206
         $default_mask = $client->getDefaultMessageMask();
207
-        if($default_mask != null) {
207
+        if ($default_mask != null) {
208 208
             $this->mask = $default_mask;
209 209
         }
210 210
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
      * @throws MessageFlagException
264 264
      * @throws Exceptions\RuntimeException
265 265
      */
266
-    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){
266
+    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) {
267 267
         $reflection = new ReflectionClass(self::class);
268 268
         /** @var self $instance */
269 269
         $instance = $reflection->newInstanceWithoutConstructor();
270 270
 
271 271
         $default_mask = $client->getDefaultMessageMask();
272
-        if($default_mask != null) {
272
+        if ($default_mask != null) {
273 273
             $instance->setMask($default_mask);
274 274
         }
275 275
         $instance->setEvents([
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
      * @throws MethodNotFoundException
305 305
      */
306 306
     public function __call($method, $arguments) {
307
-        if(strtolower(substr($method, 0, 3)) === 'get') {
307
+        if (strtolower(substr($method, 0, 3)) === 'get') {
308 308
             $name = Str::snake(substr($method, 3));
309 309
             return $this->get($name);
310 310
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
311 311
             $name = Str::snake(substr($method, 3));
312 312
 
313
-            if(in_array($name, array_keys($this->attributes))) {
313
+            if (in_array($name, array_keys($this->attributes))) {
314 314
                 return $this->__set($name, array_pop($arguments));
315 315
             }
316 316
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
      * @return mixed|null
350 350
      */
351 351
     public function get($name) {
352
-        if(isset($this->attributes[$name])) {
352
+        if (isset($this->attributes[$name])) {
353 353
             return $this->attributes[$name];
354 354
         }
355 355
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
      *
424 424
      * @throws InvalidMessageDateException
425 425
      */
426
-    public function parseRawHeader($raw_header){
426
+    public function parseRawHeader($raw_header) {
427 427
         $this->header = new Header($raw_header);
428 428
     }
429 429
 
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
     public function parseRawFlags($raw_flags) {
435 435
         $this->flags = FlagCollection::make([]);
436 436
 
437
-        foreach($raw_flags as $flag) {
438
-            if (strpos($flag, "\\") === 0){
437
+        foreach ($raw_flags as $flag) {
438
+            if (strpos($flag, "\\") === 0) {
439 439
                 $flag = substr($flag, 1);
440 440
             }
441 441
             $flag_key = strtolower($flag);
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
      * @throws MessageFlagException
509 509
      * @throws Exceptions\RuntimeException
510 510
      */
511
-    public function peek(){
511
+    public function peek() {
512 512
         if ($this->fetch_options == IMAP::FT_PEEK) {
513 513
             if ($this->getFlags()->get("seen") == null) {
514 514
                 $this->unsetFlag("Seen");
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
     private function fetchPart(Part $part) {
558 558
         if ($part->isAttachment()) {
559 559
             $this->fetchAttachment($part);
560
-        }else{
560
+        }else {
561 561
             $encoding = $this->getEncoding($part);
562 562
 
563 563
             $content = $this->decodeString($part->content, $part->encoding);
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 
583 583
             if (isset($this->bodies[$subtype])) {
584 584
                 $this->bodies[$subtype] .= "\n".$content;
585
-            }else{
585
+            }else {
586 586
                 $this->bodies[$subtype] = $content;
587 587
             }
588 588
         }
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
         if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) {
599 599
             if ($oAttachment->getId() !== null) {
600 600
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
601
-            } else {
601
+            }else {
602 602
                 $this->attachments->push($oAttachment);
603 603
             }
604 604
         }
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 
733 733
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
734 734
             return @iconv($from, $to.'//IGNORE', $str);
735
-        } else {
735
+        }else {
736 736
             if (!$from) {
737 737
                 return mb_convert_encoding($str, $to);
738 738
             }
@@ -753,9 +753,9 @@  discard block
 block discarded – undo
753 753
                     return EncodingAliases::get($parameter->value);
754 754
                 }
755 755
             }
756
-        }elseif (property_exists($structure, 'charset')){
756
+        }elseif (property_exists($structure, 'charset')) {
757 757
             return EncodingAliases::get($structure->charset);
758
-        }elseif (is_string($structure) === true){
758
+        }elseif (is_string($structure) === true) {
759 759
             return mb_detect_encoding($structure);
760 760
         }
761 761
 
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
      * @throws Exceptions\FolderFetchingException
771 771
      * @throws Exceptions\RuntimeException
772 772
      */
773
-    public function getFolder(){
773
+    public function getFolder() {
774 774
         return $this->client->getFolder($this->folder_path);
775 775
     }
776 776
 
@@ -786,13 +786,13 @@  discard block
 block discarded – undo
786 786
      * @throws Exceptions\GetMessagesFailedException
787 787
      * @throws Exceptions\RuntimeException
788 788
      */
789
-    public function thread($sent_folder = null, &$thread = null, $folder = null){
789
+    public function thread($sent_folder = null, &$thread = null, $folder = null) {
790 790
         $thread = $thread ? $thread : MessageCollection::make([]);
791
-        $folder = $folder ? $folder :  $this->getFolder();
791
+        $folder = $folder ? $folder : $this->getFolder();
792 792
         $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
793 793
 
794 794
         /** @var Message $message */
795
-        foreach($thread as $message) {
795
+        foreach ($thread as $message) {
796 796
             if ($message->message_id == $this->message_id) {
797 797
                 return $thread;
798 798
             }
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
         $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder);
804 804
 
805 805
         if (is_array($this->in_reply_to)) {
806
-            foreach($this->in_reply_to as $in_reply_to) {
806
+            foreach ($this->in_reply_to as $in_reply_to) {
807 807
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder);
808 808
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder);
809 809
             }
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
      * @throws Exceptions\GetMessagesFailedException
825 825
      * @throws Exceptions\RuntimeException
826 826
      */
827
-    protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){
827
+    protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder) {
828 828
         $primary_folder->query()->inReplyTo($in_reply_to)
829 829
         ->setFetchBody($this->getFetchBodyOption())
830 830
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
      * @throws Exceptions\GetMessagesFailedException
846 846
      * @throws Exceptions\RuntimeException
847 847
      */
848
-    protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){
848
+    protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder) {
849 849
         $primary_folder->query()->messageId($message_id)
850 850
         ->setFetchBody($this->getFetchBodyOption())
851 851
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -938,14 +938,14 @@  discard block
 block discarded – undo
938 938
      * @throws MessageFlagException
939 939
      * @throws MessageHeaderFetchingException
940 940
      */
941
-    protected function fetchNewMail($folder, $next_uid, $event, $expunge){
942
-        if($expunge) $this->client->expunge();
941
+    protected function fetchNewMail($folder, $next_uid, $event, $expunge) {
942
+        if ($expunge) $this->client->expunge();
943 943
 
944 944
         $this->client->openFolder($folder->path);
945 945
 
946 946
         if ($this->sequence === IMAP::ST_UID) {
947 947
             $sequence_id = $next_uid;
948
-        }else{
948
+        }else {
949 949
             $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
950 950
         }
951 951
 
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
      */
969 969
     public function delete($expunge = true) {
970 970
         $status = $this->setFlag("Deleted");
971
-        if($expunge) $this->client->expunge();
971
+        if ($expunge) $this->client->expunge();
972 972
 
973 973
         $event = $this->getEvent("message", "deleted");
974 974
         $event::dispatch($this);
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
      */
989 989
     public function restore($expunge = true) {
990 990
         $status = $this->unsetFlag("Deleted");
991
-        if($expunge) $this->client->expunge();
991
+        if ($expunge) $this->client->expunge();
992 992
 
993 993
         $event = $this->getEvent("message", "restored");
994 994
         $event::dispatch($this);
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
      *
1094 1094
      * @return AttachmentCollection
1095 1095
      */
1096
-    public function attachments(){
1096
+    public function attachments() {
1097 1097
         return $this->getAttachments();
1098 1098
     }
1099 1099
 
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
      *
1192 1192
      * @return FlagCollection
1193 1193
      */
1194
-    public function flags(){
1194
+    public function flags() {
1195 1195
         return $this->getFlags();
1196 1196
     }
1197 1197
 
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
      *
1201 1201
      * @return Structure|null
1202 1202
      */
1203
-    public function getStructure(){
1203
+    public function getStructure() {
1204 1204
         return $this->structure;
1205 1205
     }
1206 1206
 
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
      *
1227 1227
      * @return array
1228 1228
      */
1229
-    public function getAttributes(){
1229
+    public function getAttributes() {
1230 1230
         return array_merge($this->attributes, $this->header->getAttributes());
1231 1231
     }
1232 1232
 
@@ -1236,8 +1236,8 @@  discard block
 block discarded – undo
1236 1236
      *
1237 1237
      * @return $this
1238 1238
      */
1239
-    public function setMask($mask){
1240
-        if(class_exists($mask)){
1239
+    public function setMask($mask) {
1240
+        if (class_exists($mask)) {
1241 1241
             $this->mask = $mask;
1242 1242
         }
1243 1243
 
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
      *
1250 1250
      * @return string
1251 1251
      */
1252
-    public function getMask(){
1252
+    public function getMask() {
1253 1253
         return $this->mask;
1254 1254
     }
1255 1255
 
@@ -1260,9 +1260,9 @@  discard block
 block discarded – undo
1260 1260
      * @return mixed
1261 1261
      * @throws MaskNotFoundException
1262 1262
      */
1263
-    public function mask($mask = null){
1263
+    public function mask($mask = null) {
1264 1264
         $mask = $mask !== null ? $mask : $this->mask;
1265
-        if(class_exists($mask)){
1265
+        if (class_exists($mask)) {
1266 1266
             return new $mask($this);
1267 1267
         }
1268 1268
 
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
      *
1276 1276
      * @return $this
1277 1277
      */
1278
-    public function setFolderPath($folder_path){
1278
+    public function setFolderPath($folder_path) {
1279 1279
         $this->folder_path = $folder_path;
1280 1280
 
1281 1281
         return $this;
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
      *
1288 1288
      * @return $this
1289 1289
      */
1290
-    public function setConfig($config){
1290
+    public function setConfig($config) {
1291 1291
         $this->config = $config;
1292 1292
 
1293 1293
         return $this;
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
      *
1300 1300
      * @return $this
1301 1301
      */
1302
-    public function setAvailableFlags($available_flags){
1302
+    public function setAvailableFlags($available_flags) {
1303 1303
         $this->available_flags = $available_flags;
1304 1304
 
1305 1305
         return $this;
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
      *
1312 1312
      * @return $this
1313 1313
      */
1314
-    public function setAttachments($attachments){
1314
+    public function setAttachments($attachments) {
1315 1315
         $this->attachments = $attachments;
1316 1316
 
1317 1317
         return $this;
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
      *
1324 1324
      * @return $this
1325 1325
      */
1326
-    public function setFlags($flags){
1326
+    public function setFlags($flags) {
1327 1327
         $this->flags = $flags;
1328 1328
 
1329 1329
         return $this;
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
      * @throws Exceptions\RuntimeException
1338 1338
      * @throws Exceptions\ConnectionFailedException
1339 1339
      */
1340
-    public function setClient($client){
1340
+    public function setClient($client) {
1341 1341
         $this->client = $client;
1342 1342
         $this->client->openFolder($this->folder_path);
1343 1343
 
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
      * @throws Exceptions\RuntimeException
1353 1353
      * @return $this
1354 1354
      */
1355
-    public function setUid($uid){
1355
+    public function setUid($uid) {
1356 1356
         $this->uid = $uid;
1357 1357
         $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid);
1358 1358
         $this->msglist = null;
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
      * @throws Exceptions\RuntimeException
1370 1370
      * @return $this
1371 1371
      */
1372
-    public function setMsgn($msgn, $msglist = null){
1372
+    public function setMsgn($msgn, $msglist = null) {
1373 1373
         $this->msgn = $msgn;
1374 1374
         $this->msglist = $msglist;
1375 1375
         $this->uid = $this->client->getConnection()->getUid($this->msgn);
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
      *
1383 1383
      * @return int
1384 1384
      */
1385
-    public function getSequence(){
1385
+    public function getSequence() {
1386 1386
         return $this->sequence;
1387 1387
     }
1388 1388
 
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
      *
1392 1392
      * @return int
1393 1393
      */
1394
-    public function getSequenceId(){
1394
+    public function getSequenceId() {
1395 1395
         return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn;
1396 1396
     }
1397 1397
 
@@ -1403,11 +1403,11 @@  discard block
 block discarded – undo
1403 1403
      * @throws Exceptions\ConnectionFailedException
1404 1404
      * @throws Exceptions\RuntimeException
1405 1405
      */
1406
-    public function setSequenceId($uid, $msglist = null){
1406
+    public function setSequenceId($uid, $msglist = null) {
1407 1407
         if ($this->getSequence() === IMAP::ST_UID) {
1408 1408
             $this->setUid($uid);
1409 1409
             $this->setMsglist($msglist);
1410
-        }else{
1410
+        }else {
1411 1411
             $this->setMsgn($uid, $msglist);
1412 1412
         }
1413 1413
     }
Please login to merge, or discard this patch.
src/Support/Masks/MessageMask.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @return null
32 32
      */
33
-    public function getHtmlBody(){
33
+    public function getHtmlBody() {
34 34
         $bodies = $this->parent->getBodies();
35 35
         if (!isset($bodies['html'])) {
36 36
             return null;
37 37
         }
38 38
 
39
-        if(is_object($bodies['html']) && property_exists($bodies['html'], 'content')) {
39
+        if (is_object($bodies['html']) && property_exists($bodies['html'], 'content')) {
40 40
             return $bodies['html']->content;
41 41
         }
42 42
         return $bodies['html'];
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function getCustomHTMLBody($callback = false) {
52 52
         $body = $this->getHtmlBody();
53
-        if($body === null) return null;
53
+        if ($body === null) return null;
54 54
 
55 55
         if ($callback !== false) {
56 56
             $aAttachment = $this->parent->getAttachments();
57 57
             $aAttachment->each(function($oAttachment) use(&$body, $callback) {
58 58
                 /** @var Attachment $oAttachment */
59
-                if(is_callable($callback)) {
59
+                if (is_callable($callback)) {
60 60
                     $body = $callback($body, $oAttachment);
61
-                }elseif(is_string($callback)) {
61
+                }elseif (is_string($callback)) {
62 62
                     call_user_func($callback, [$body, $oAttachment]);
63 63
                 }
64 64
             });
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @return string|null
75 75
      */
76 76
     public function getHTMLBodyWithEmbeddedBase64Images() {
77
-        return $this->getCustomHTMLBody(function($body, $oAttachment){
77
+        return $this->getCustomHTMLBody(function($body, $oAttachment) {
78 78
             /** @var Attachment $oAttachment */
79 79
             if ($oAttachment->id) {
80 80
                 $body = str_replace('cid:'.$oAttachment->id, 'data:'.$oAttachment->getContentType().';base64, '.base64_encode($oAttachment->getContent()), $body);
Please login to merge, or discard this patch.