Passed
Pull Request — master (#242)
by
unknown
02:35
created
examples/custom_message_mask.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
      * New custom method which can be called through a mask
17 17
      * @return string
18 18
      */
19
-    public function token(){
19
+    public function token() {
20 20
         return implode('-', [$this->message_id, $this->uid, $this->message_no]);
21 21
     }
22 22
 
Please login to merge, or discard this patch.
examples/custom_attachment_mask.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
      * New custom method which can be called through a mask
17 17
      * @return string
18 18
      */
19
-    public function token(){
19
+    public function token() {
20 20
         return implode('-', [$this->id, $this->getMessage()->getUid(), $this->name]);
21 21
     }
22 22
 
Please login to merge, or discard this patch.
src/Support/Masks/Mask.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
                 return $this->attributes[$name];
68 68
             }
69 69
 
70
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
70
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
71 71
             $name = Str::snake(substr($method, 3));
72 72
 
73 73
             if(isset($this->attributes[$name])) {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function __construct(object $parent) {
42 42
         $this->parent = $parent;
43 43
 
44
-        if(method_exists($this->parent, 'getAttributes')){
44
+        if (method_exists($this->parent, 'getAttributes')) {
45 45
             $this->attributes = array_merge($this->attributes, $this->parent->getAttributes());
46 46
         }
47 47
 
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
      * @throws MethodNotFoundException
63 63
      */
64 64
     public function __call(string $method, array $arguments) {
65
-        if(strtolower(substr($method, 0, 3)) === 'get') {
65
+        if (strtolower(substr($method, 0, 3)) === 'get') {
66 66
             $name = Str::snake(substr($method, 3));
67 67
 
68
-            if(isset($this->attributes[$name])) {
68
+            if (isset($this->attributes[$name])) {
69 69
                 return $this->attributes[$name];
70 70
             }
71 71
 
72 72
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
73 73
             $name = Str::snake(substr($method, 3));
74 74
 
75
-            if(isset($this->attributes[$name])) {
75
+            if (isset($this->attributes[$name])) {
76 76
                 $this->attributes[$name] = array_pop($arguments);
77 77
 
78 78
                 return $this->attributes[$name];
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
         }
82 82
 
83
-        if(method_exists($this->parent, $method) === true){
83
+        if (method_exists($this->parent, $method) === true) {
84 84
             return call_user_func_array([$this->parent, $method], $arguments);
85 85
         }
86 86
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      * @return mixed|null
108 108
      */
109 109
     public function __get($name) {
110
-        if(isset($this->attributes[$name])) {
110
+        if (isset($this->attributes[$name])) {
111 111
             return $this->attributes[$name];
112 112
         }
113 113
 
Please login to merge, or discard this patch.
src/Connection/Protocols/Protocol.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
         // so add them back in manually if we can
56 56
         if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
57 57
             $cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
58
-        }elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT')) {
58
+        } elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT')) {
59 59
             $cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
60 60
         }
61 61
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@
 block discarded – undo
246 246
         if (is_numeric($uid)) {
247 247
             return "";
248 248
         }
249
-        return (string)$uid;
249
+        return (string) $uid;
250 250
     }
251 251
 
252 252
     public function buildUIDCommand($command, $uid) : string {
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/Connection/Protocols/LegacyProtocol.php 2 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
                 $name = $this->decodeFolderName($item->name);
324 324
                 $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []];
325 325
             }
326
-        }else{
326
+        } else{
327 327
             throw new RuntimeException(\imap_last_error());
328 328
         }
329 329
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
         if ($mode == "+"){
349 349
             $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
350
-        }else{
350
+        } else{
351 351
             $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
352 352
         }
353 353
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
             throw new AuthFailedException($message);
89 89
         }
90 90
 
91
-        if(!$this->stream) {
91
+        if (!$this->stream) {
92 92
             $errors = \imap_errors();
93 93
             $message = implode("; ", (is_array($errors) ? $errors : array()));
94 94
             throw new AuthFailedException($message);
95 95
         }
96 96
 
97 97
         $errors = \imap_errors();
98
-        if(is_array($errors)) {
98
+        if (is_array($errors)) {
99 99
             $status = $this->examineFolder();
100
-            if($status['exists'] !== 0) {
100
+            if ($status['exists'] !== 0) {
101 101
                 $message = implode("; ", (is_array($errors) ? $errors : array()));
102 102
                 throw new RuntimeException($message);
103 103
             }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         if (!$this->cert_validation) {
129 129
             $address .= '/novalidate-cert';
130 130
         }
131
-        if (in_array($this->encryption,['tls', 'notls', 'ssl'])) {
131
+        if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) {
132 132
             $address .= '/'.$this->encryption;
133 133
         } elseif ($this->encryption === "starttls") {
134 134
             $address .= '/tls';
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
             $overview = $this->overview("1:*");
288 288
             $uids = [];
289
-            foreach($overview as $set){
289
+            foreach ($overview as $set) {
290 290
                 $uids[$set->msgno] = $set->uid;
291 291
             }
292 292
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      * @return array
316 316
      */
317 317
     public function overview(string $sequence, $uid = IMAP::ST_UID): array {
318
-        return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL);
318
+        return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::ST_UID : IMAP::NIL);
319 319
     }
320 320
 
321 321
     /**
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
         $result = [];
331 331
 
332 332
         $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder);
333
-        if(is_array($items)){
333
+        if (is_array($items)) {
334 334
             foreach ($items as $item) {
335 335
                 $name = $this->decodeFolderName($item->name);
336 336
                 $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []];
337 337
             }
338
-        }else{
338
+        }else {
339 339
             throw new RuntimeException(\imap_last_error());
340 340
         }
341 341
 
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
     public function store(array $flags, int $from, $to = null, $mode = null, bool $silent = true, $uid = IMAP::ST_UID, $item = null) {
359 359
         $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags);
360 360
 
361
-        if ($mode == "+"){
361
+        if ($mode == "+") {
362 362
             $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
363
-        }else{
363
+        }else {
364 364
             $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
365 365
         }
366 366
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     public function appendMessage(string $folder, string $message, $flags = null, $date = null): bool {
384 384
         if ($date != null) {
385
-            if ($date instanceof \Carbon\Carbon){
385
+            if ($date instanceof \Carbon\Carbon) {
386 386
                 $date = $date->format('d-M-Y H:i:s O');
387 387
             }
388 388
             return \imap_append($this->stream, $folder, $message, $flags, $date);
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
      * @return array|bool Tokens if operation successful, false if an error occurred
415 415
      */
416 416
     public function copyManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) {
417
-        foreach($messages as $msg) {
417
+        foreach ($messages as $msg) {
418 418
             if ($this->copyMessage($folder, $msg, null, $uid) == false) {
419 419
                 return false;
420 420
             }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
      * @return array|bool Tokens if operation successful, false if an error occurred
447 447
      */
448 448
     public function moveManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) {
449
-        foreach($messages as $msg) {
449
+        foreach ($messages as $msg) {
450 450
             if ($this->moveMessage($folder, $msg, null, $uid) == false) {
451 451
                 return false;
452 452
             }
Please login to merge, or discard this patch.
src/Query/Query.php 2 patches
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -91,7 +91,9 @@  discard block
 block discarded – undo
91 91
         $this->setClient($client);
92 92
 
93 93
         $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN);
94
-        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
94
+        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) {
95
+            $this->leaveUnread();
96
+        }
95 97
 
96 98
         if (ClientManager::get('options.fetch_order') === 'desc') {
97 99
             $this->fetch_order = 'desc';
@@ -137,7 +139,9 @@  discard block
 block discarded – undo
137 139
      * @throws MessageSearchValidationException
138 140
      */
139 141
     protected function parse_date($date): Carbon {
140
-        if ($date instanceof Carbon) return $date;
142
+        if ($date instanceof Carbon) {
143
+            return $date;
144
+        }
141 145
 
142 146
         try {
143 147
             $date = Carbon::parse($date);
@@ -644,7 +648,9 @@  discard block
 block discarded – undo
644 648
      * @return $this
645 649
      */
646 650
     public function limit(int $limit, int $page = 1): Query {
647
-        if ($page >= 1) $this->page = $page;
651
+        if ($page >= 1) {
652
+            $this->page = $page;
653
+        }
648 654
         $this->limit = $limit;
649 655
 
650 656
         return $this;
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
         if (ClientManager::get('options.fetch_order') === 'desc') {
87 87
             $this->fetch_order = 'desc';
88
-        } else {
88
+        }else {
89 89
             $this->fetch_order = 'asc';
90 90
         }
91 91
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 break;
117 117
         }
118 118
 
119
-        return (string)$value;
119
+        return (string) $value;
120 120
     }
121 121
 
122 122
     /**
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
         $this->query->each(function($statement) use (&$query): void {
149 149
             if ((is_countable($statement) ? count($statement) : 0) == 1) {
150 150
                 $query .= $statement[0];
151
-            } else {
151
+            }else {
152 152
                 if ($statement[1] === null) {
153 153
                     $query .= $statement[0];
154
-                } else {
154
+                }else {
155 155
                     if (is_numeric($statement[1])) {
156
-                        $query .= $statement[0] . ' ' . $statement[1];
157
-                    } else {
158
-                        $query .= $statement[0] . ' "' . $statement[1] . '"';
156
+                        $query .= $statement[0].' '.$statement[1];
157
+                    }else {
158
+                        $query .= $statement[0].' "'.$statement[1].'"';
159 159
                     }
160 160
                 }
161 161
             }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         try {
181 181
             $available_messages = $this->client->getConnection()->search([$this->getRawQuery()], $this->sequence);
182 182
             return $available_messages !== false ? new Collection($available_messages) : new Collection();
183
-        } catch (RuntimeException|ConnectionFailedException $e) {
183
+        } catch (RuntimeException | ConnectionFailedException $e) {
184 184
             throw new GetMessagesFailedException("failed to fetch messages", 0, $e);
185 185
         }
186 186
     }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     protected function make(int $uid, int $msglist, string $header, string $content, array $flags) {
247 247
         try {
248 248
             return Message::make($uid, $msglist, $this->getClient(), $header, $content, $flags, $this->getFetchOptions(), $this->sequence);
249
-        } catch (MessageNotFoundException|RuntimeException|MessageFlagException|InvalidMessageDateException|MessageContentFetchingException $e) {
249
+        } catch (MessageNotFoundException | RuntimeException | MessageFlagException | InvalidMessageDateException | MessageContentFetchingException $e) {
250 250
             $this->setError($uid, $e);
251 251
         }
252 252
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
                 $key = $message->getMessageId();
279 279
                 break;
280 280
         }
281
-        return (string)$key;
281
+        return (string) $key;
282 282
     }
283 283
 
284 284
     /**
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
             $extensions = $raw_messages["extensions"][$uid] ?? [];
327 327
 
328 328
             $message = $this->make($uid, $msglist, $header, $content, $flag);
329
-            foreach($extensions as $key => $extension) {
329
+            foreach ($extensions as $key => $extension) {
330 330
                 $message->getHeader()->set($key, $extension);
331 331
             }
332 332
             if ($message !== null) {
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
         $uids = $connection->getUid();
479 479
         $available_messages = new Collection();
480 480
         if (is_array($uids)) {
481
-            foreach ($uids as $id){
481
+            foreach ($uids as $id) {
482 482
                 if ($closure($id)) {
483 483
                     $available_messages->push($id);
484 484
                 }
Please login to merge, or discard this patch.
src/Folder.php 2 patches
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -240,7 +240,9 @@  discard block
 block discarded – undo
240 240
     public function move(string $new_name, bool $expunge = true): bool {
241 241
         $this->client->checkConnection();
242 242
         $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name);
243
-        if($expunge) $this->client->expunge();
243
+        if($expunge) {
244
+            $this->client->expunge();
245
+        }
244 246
 
245 247
         $folder = $this->client->getFolder($new_name);
246 248
         $event = $this->getEvent("folder", "moved");
@@ -316,7 +318,9 @@  discard block
 block discarded – undo
316 318
      */
317 319
     public function delete(bool $expunge = true): bool {
318 320
         $status = $this->client->getConnection()->deleteFolder($this->path);
319
-        if($expunge) $this->client->expunge();
321
+        if($expunge) {
322
+            $this->client->expunge();
323
+        }
320 324
 
321 325
         $event = $this->getEvent("folder", "deleted");
322 326
         $event::dispatch($this);
@@ -394,7 +398,7 @@  discard block
 block discarded – undo
394 398
 
395 399
                     $connection->idle();
396 400
                 }
397
-            }catch (Exceptions\RuntimeException $e) {
401
+            } catch (Exceptions\RuntimeException $e) {
398 402
                 if(strpos($e->getMessage(), "connection closed") === false) {
399 403
                     throw $e;
400 404
                 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
         $this->setDelimiter($delimiter);
121 121
         $this->path      = $folder_name;
122
-        $this->full_name  = $this->decodeName($folder_name);
122
+        $this->full_name = $this->decodeName($folder_name);
123 123
         $this->name      = $this->getSimpleName($this->delimiter, $this->full_name);
124 124
 
125 125
         $this->parseAttributes($attributes);
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     public function move(string $new_name, bool $expunge = true): bool {
231 231
         $this->client->checkConnection();
232 232
         $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name);
233
-        if($expunge) $this->client->expunge();
233
+        if ($expunge) $this->client->expunge();
234 234
 
235 235
         $folder = $this->client->getFolder($new_name);
236 236
         $event = $this->getEvent("folder", "moved");
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
          * date string that conforms to the rfc2060 specifications for a date_time value or be a Carbon object.
274 274
          */
275 275
 
276
-        if ($internal_date instanceof Carbon){
276
+        if ($internal_date instanceof Carbon) {
277 277
             $internal_date = $internal_date->format('d-M-Y H:i:s O');
278 278
         }
279 279
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
      */
307 307
     public function delete(bool $expunge = true): bool {
308 308
         $status = $this->client->getConnection()->deleteFolder($this->path);
309
-        if($expunge) $this->client->expunge();
309
+        if ($expunge) $this->client->expunge();
310 310
 
311 311
         $event = $this->getEvent("folder", "deleted");
312 312
         $event::dispatch($this);
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
             try {
372 372
                 $line = $connection->nextLine();
373 373
                 if (($pos = strpos($line, "EXISTS")) !== false) {
374
-                    $msgn = (int) substr($line, 2, $pos -2);
374
+                    $msgn = (int) substr($line, 2, $pos - 2);
375 375
                     $connection->done();
376 376
 
377 377
                     $this->client->openFolder($this->path, true);
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
 
385 385
                     $connection->idle();
386 386
                 }
387
-            }catch (Exceptions\RuntimeException $e) {
388
-                if(strpos($e->getMessage(), "connection closed") === false) {
387
+            } catch (Exceptions\RuntimeException $e) {
388
+                if (strpos($e->getMessage(), "connection closed") === false) {
389 389
                     throw $e;
390 390
                 }
391 391
                 if ($auto_reconnect === true) {
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
      * @param mixed $delimiter
436 436
      */
437 437
     public function setDelimiter(string $delimiter): void {
438
-        if(in_array($delimiter, [null, '', ' ', false]) === true) {
438
+        if (in_array($delimiter, [null, '', ' ', false]) === true) {
439 439
             $delimiter = ClientManager::get('options.delimiter', '/');
440 440
         }
441 441
 
Please login to merge, or discard this patch.