Passed
Push — master ( 812ed7...044883 )
by Malte
02:04
created
src/Folder.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         $this->setDelimiter($delimiter);
127 127
         $this->path      = $folder_name;
128
-        $this->full_name  = $this->decodeName($folder_name);
128
+        $this->full_name = $this->decodeName($folder_name);
129 129
         $this->name      = $this->getSimpleName($this->delimiter, $this->full_name);
130 130
 
131 131
         $this->parseAttributes($attributes);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @return WhereQuery
139 139
      * @throws Exceptions\ConnectionFailedException
140 140
      */
141
-    public function query($charset = 'UTF-8'){
141
+    public function query($charset = 'UTF-8') {
142 142
         $this->getClient()->checkConnection();
143 143
         $this->getClient()->openFolder($this->path);
144 144
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      * @inheritdoc self::query($charset = 'UTF-8')
150 150
      * @throws Exceptions\ConnectionFailedException
151 151
      */
152
-    public function search($charset = 'UTF-8'){
152
+    public function search($charset = 'UTF-8') {
153 153
         return $this->query($charset);
154 154
     }
155 155
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      * @inheritdoc self::query($charset = 'UTF-8')
158 158
      * @throws Exceptions\ConnectionFailedException
159 159
      */
160
-    public function messages($charset = 'UTF-8'){
160
+    public function messages($charset = 'UTF-8') {
161 161
         return $this->query($charset);
162 162
     }
163 163
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
     public function move($new_name, $expunge = true) {
233 233
         $this->client->checkConnection();
234 234
         $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name);
235
-        if($expunge) $this->client->expunge();
235
+        if ($expunge) $this->client->expunge();
236 236
 
237 237
         $folder = $this->client->getFolder($new_name);
238 238
         $event = $this->getEvent("folder", "moved");
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
      * @return array
249 249
      * @throws ConnectionFailedException
250 250
      */
251
-    public function overview($sequence = null){
251
+    public function overview($sequence = null) {
252 252
         $this->client->openFolder($this->path);
253 253
         $sequence = $sequence === null ? "1:*" : $sequence;
254 254
         return $this->client->getConnection()->overview($sequence);
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
          */
273 273
 
274 274
         if ($internal_date != null) {
275
-            if ($internal_date instanceof Carbon){
275
+            if ($internal_date instanceof Carbon) {
276 276
                 $internal_date = $internal_date->format('d-M-Y H:i:s O');
277 277
             }
278 278
         }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
      */
307 307
     public function delete($expunge = true) {
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);
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             try {
362 362
                 $line = $connection->nextLine();
363 363
                 if (($pos = strpos($line, "EXISTS")) !== false) {
364
-                    $msgn = (int) substr($line, 2, $pos -2);
364
+                    $msgn = (int) substr($line, 2, $pos - 2);
365 365
                     $connection->done();
366 366
 
367 367
                     $message = $this->query()->getMessage($msgn);
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 
373 373
                     $connection->idle();
374 374
                 }
375
-            }catch (Exceptions\RuntimeException $e) {
376
-                if(strpos($e->getMessage(), "connection closed") === false) {
375
+            } catch (Exceptions\RuntimeException $e) {
376
+                if (strpos($e->getMessage(), "connection closed") === false) {
377 377
                     throw $e;
378
-                }else{
378
+                }else {
379 379
                     $this->client->connect();
380 380
                     $this->client->openFolder($this->path);
381 381
                     $connection = $this->client->getConnection();
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
      * Set the delimiter
421 421
      * @param $delimiter
422 422
      */
423
-    public function setDelimiter($delimiter){
424
-        if(in_array($delimiter, [null, '', ' ', false]) === true) {
423
+    public function setDelimiter($delimiter) {
424
+        if (in_array($delimiter, [null, '', ' ', false]) === true) {
425 425
             $delimiter = ClientManager::get('options.delimiter', '/');
426 426
         }
427 427
 
Please login to merge, or discard this patch.
src/Connection/Protocols/ImapProtocol.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      * @throws ConnectionFailedException
84 84
      * @throws RuntimeException
85 85
      */
86
-    protected function enableTls(){
86
+    protected function enableTls() {
87 87
         $response = $this->requestAndResponse('STARTTLS');
88 88
         $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod());
89 89
         if (!$result) {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $stack = [];
146 146
 
147 147
         //  replace any trailing <NL> including spaces with a single space
148
-        $line = rtrim($line) . ' ';
148
+        $line = rtrim($line).' ';
149 149
         while (($pos = strpos($line, ' ')) !== false) {
150 150
             $token = substr($line, 0, $pos);
151 151
             if (!strlen($token)) {
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
                     if (strlen($token) > $chars) {
176 176
                         $line = substr($token, $chars);
177 177
                         $token = substr($token, 0, $chars);
178
-                    } else {
178
+                    }else {
179 179
                         $line .= $this->nextLine();
180 180
                     }
181 181
                     $tokens[] = $token;
182
-                    $line = trim($line) . ' ';
182
+                    $line = trim($line).' ';
183 183
                     continue;
184 184
                 }
185 185
             }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         $line = $this->nextTaggedLine($tag); // get next tag
230 230
         if (!$dontParse) {
231 231
             $tokens = $this->decodeLine($line);
232
-        } else {
232
+        }else {
233 233
             $tokens = $line;
234 234
         }
235 235
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
             // First two chars are still needed for the response code
257 257
             $tokens = [substr($tokens, 0, 2)];
258 258
         }
259
-        if (is_array($lines)){
259
+        if (is_array($lines)) {
260 260
             if ($this->debug) echo "<< ".json_encode($lines)."\n";
261
-        }else{
261
+        }else {
262 262
             if ($this->debug) echo "<< ".$lines."\n";
263 263
         }
264 264
 
@@ -283,27 +283,27 @@  discard block
 block discarded – undo
283 283
     public function sendRequest($command, $tokens = [], &$tag = null) {
284 284
         if (!$tag) {
285 285
             $this->noun++;
286
-            $tag = 'TAG' . $this->noun;
286
+            $tag = 'TAG'.$this->noun;
287 287
         }
288 288
 
289
-        $line = $tag . ' ' . $command;
289
+        $line = $tag.' '.$command;
290 290
 
291 291
         foreach ($tokens as $token) {
292 292
             if (is_array($token)) {
293
-                if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) {
293
+                if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) {
294 294
                     throw new RuntimeException('failed to write - connection closed?');
295 295
                 }
296 296
                 if (!$this->assumedNextLine('+ ')) {
297 297
                     throw new RuntimeException('failed to send literal string');
298 298
                 }
299 299
                 $line = $token[1];
300
-            } else {
301
-                $line .= ' ' . $token;
300
+            }else {
301
+                $line .= ' '.$token;
302 302
             }
303 303
         }
304 304
         if ($this->debug) echo ">> ".$line."\n";
305 305
 
306
-        if (fwrite($this->stream, $line . "\r\n") === false) {
306
+        if (fwrite($this->stream, $line."\r\n") === false) {
307 307
             throw new RuntimeException('failed to write - connection closed?');
308 308
         }
309 309
     }
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
     public function escapeString($string) {
334 334
         if (func_num_args() < 2) {
335 335
             if (strpos($string, "\n") !== false) {
336
-                return ['{' . strlen($string) . '}', $string];
337
-            } else {
338
-                return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
336
+                return ['{'.strlen($string).'}', $string];
337
+            }else {
338
+                return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"';
339 339
             }
340 340
         }
341 341
         $result = [];
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
             }
361 361
             $result[] = $this->escapeList($v);
362 362
         }
363
-        return '(' . implode(' ', $result) . ')';
363
+        return '('.implode(' ', $result).')';
364 364
     }
365 365
 
366 366
     /**
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
                     error_log("got an extra server challenge: $response");
401 401
                     // respond with an empty response.
402 402
                     $this->sendRequest('');
403
-                } else {
403
+                }else {
404 404
                     if (preg_match('/^NO /i', $response) ||
405 405
                         preg_match('/^BAD /i', $response)) {
406 406
                         error_log("got failure response: $response");
407 407
                         return false;
408
-                    } else if (preg_match("/^OK /i", $response)) {
408
+                    }else if (preg_match("/^OK /i", $response)) {
409 409
                         return true;
410 410
                     }
411 411
                 }
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
      *
439 439
      * @return bool
440 440
      */
441
-    public function connected(){
441
+    public function connected() {
442 442
         return (boolean) $this->stream;
443 443
     }
444 444
 
@@ -485,10 +485,10 @@  discard block
 block discarded – undo
485 485
                     $result[strtolower($tokens[1])] = $tokens[0];
486 486
                     break;
487 487
                 case '[UIDVALIDITY':
488
-                    $result['uidvalidity'] = (int)$tokens[2];
488
+                    $result['uidvalidity'] = (int) $tokens[2];
489 489
                     break;
490 490
                 case '[UIDNEXT':
491
-                    $result['uidnext'] = (int)$tokens[2];
491
+                    $result['uidnext'] = (int) $tokens[2];
492 492
                     break;
493 493
                 default:
494 494
                     // ignore
@@ -542,17 +542,17 @@  discard block
 block discarded – undo
542 542
         if (is_array($from)) {
543 543
             $set = implode(',', $from);
544 544
         } elseif ($to === null) {
545
-            $set = (int)$from;
545
+            $set = (int) $from;
546 546
         } elseif ($to === INF) {
547
-            $set = (int)$from . ':*';
548
-        } else {
549
-            $set = (int)$from . ':' . (int)$to;
547
+            $set = (int) $from.':*';
548
+        }else {
549
+            $set = (int) $from.':'.(int) $to;
550 550
         }
551 551
 
552
-        $items = (array)$items;
552
+        $items = (array) $items;
553 553
         $itemList = $this->escapeList($items);
554 554
 
555
-        $this->sendRequest(($uid ? 'UID ' : '') . 'FETCH', [$set, $itemList], $tag);
555
+        $this->sendRequest(($uid ? 'UID ' : '').'FETCH', [$set, $itemList], $tag);
556 556
 
557 557
         $result = [];
558 558
         $tokens = null; // define $tokens variable before first use
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
                 $count = count($tokens[2]);
568 568
                 if ($tokens[2][$count - 2] == 'UID') {
569 569
                     $uidKey = $count - 1;
570
-                } else {
570
+                }else {
571 571
                     $uidKey = array_search('UID', $tokens[2]) + 1;
572 572
                 }
573 573
             }
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
                     $data = $tokens[2][1];
584 584
                 } elseif ($uid && $tokens[2][2] == $items[0]) {
585 585
                     $data = $tokens[2][3];
586
-                } else {
586
+                }else {
587 587
                     // maybe the server send an other field we didn't wanted
588 588
                     $count = count($tokens[2]);
589 589
                     // we start with 2, because 0 was already checked
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
                         break;
596 596
                     }
597 597
                 }
598
-            } else {
598
+            }else {
599 599
                 $data = [];
600 600
                 while (key($tokens[2]) !== null) {
601 601
                     $data[current($tokens[2])] = next($tokens[2]);
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      * @return array
641 641
      * @throws RuntimeException
642 642
      */
643
-    public function headers($uids, $rfc = "RFC822"){
643
+    public function headers($uids, $rfc = "RFC822") {
644 644
         return $this->fetch(["$rfc.HEADER"], $uids);
645 645
     }
646 646
 
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
      * @return array
652 652
      * @throws RuntimeException
653 653
      */
654
-    public function flags($uids){
654
+    public function flags($uids) {
655 655
         return $this->fetch(["FLAGS"], $uids);
656 656
     }
657 657
 
@@ -735,22 +735,22 @@  discard block
 block discarded – undo
735 735
     public function store(array $flags, $from, $to = null, $mode = null, $silent = true) {
736 736
         $item = 'FLAGS';
737 737
         if ($mode == '+' || $mode == '-') {
738
-            $item = $mode . $item;
738
+            $item = $mode.$item;
739 739
         }
740 740
         if ($silent) {
741 741
             $item .= '.SILENT';
742 742
         }
743 743
 
744 744
         $flags = $this->escapeList($flags);
745
-        $set = (int)$from;
745
+        $set = (int) $from;
746 746
         if ($to !== null) {
747
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
747
+            $set .= ':'.($to == INF ? '*' : (int) $to);
748 748
         }
749 749
 
750 750
         $result = $this->requestAndResponse('STORE', [$set, $item, $flags], $silent);
751 751
 
752 752
         if ($silent) {
753
-            return (bool)$result;
753
+            return (bool) $result;
754 754
         }
755 755
 
756 756
         $tokens = $result;
@@ -800,9 +800,9 @@  discard block
 block discarded – undo
800 800
      * @throws RuntimeException
801 801
      */
802 802
     public function copyMessage($folder, $from, $to = null) {
803
-        $set = (int)$from;
803
+        $set = (int) $from;
804 804
         if ($to !== null) {
805
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
805
+            $set .= ':'.($to == INF ? '*' : (int) $to);
806 806
         }
807 807
 
808 808
         return $this->requestAndResponse('COPY', [$set, $this->escapeString($folder)], true);
@@ -819,9 +819,9 @@  discard block
 block discarded – undo
819 819
      * @throws RuntimeException
820 820
      */
821 821
     public function moveMessage($folder, $from, $to = null) {
822
-        $set = (int)$from;
822
+        $set = (int) $from;
823 823
         if ($to !== null) {
824
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
824
+            $set .= ':'.($to == INF ? '*' : (int) $to);
825 825
         }
826 826
 
827 827
         return $this->requestAndResponse('MOVE', [$set, $this->escapeString($folder)], true);
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
         $uids = $this->getUid();
985 985
         $ids = [];
986 986
         foreach ($uids as $msgn => $v) {
987
-            if ( ($to >= $msgn && $from <= $msgn) || ($to === "*" && $from <= $msgn) ){
987
+            if (($to >= $msgn && $from <= $msgn) || ($to === "*" && $from <= $msgn)) {
988 988
                 $ids[] = $msgn;
989 989
             }
990 990
         }
@@ -998,14 +998,14 @@  discard block
 block discarded – undo
998 998
     /**
999 999
      * Enable the debug mode
1000 1000
      */
1001
-    public function enableDebug(){
1001
+    public function enableDebug() {
1002 1002
         $this->debug = true;
1003 1003
     }
1004 1004
 
1005 1005
     /**
1006 1006
      * Disable the debug mode
1007 1007
      */
1008
-    public function disableDebug(){
1008
+    public function disableDebug() {
1009 1009
         $this->debug = false;
1010 1010
     }
1011 1011
 }
1012 1012
\ No newline at end of file
Please login to merge, or discard this patch.