Completed
Push — master ( 9127cb...6c003f )
by Lars
13:00
created
src/BounceMailHandler/BounceMailHandler.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -311,16 +311,16 @@  discard block
 block discarded – undo
311 311
     public function globalDelete(): bool
312 312
     {
313 313
         $dateArr = \explode('-', $this->deleteMsgDate); // date format is yyyy-mm-dd
314
-        $delDate = \mktime(0, 0, 0, (int) ($dateArr[1]), (int) ($dateArr[2]), (int) ($dateArr[0]));
314
+        $delDate = \mktime(0, 0, 0, (int)($dateArr[1]), (int)($dateArr[2]), (int)($dateArr[0]));
315 315
 
316
-        $port = $this->port . '/' . $this->service . '/' . $this->serviceOption;
317
-        $mboxt = \imap_open('{' . $this->mailhost . ':' . $port . '}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
316
+        $port = $this->port.'/'.$this->service.'/'.$this->serviceOption;
317
+        $mboxt = \imap_open('{'.$this->mailhost.':'.$port.'}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
318 318
 
319 319
         if ($mboxt === false) {
320 320
             return false;
321 321
         }
322 322
 
323
-        $list = \imap_getmailboxes($mboxt, '{' . $this->mailhost . ':' . $port . '}', '*');
323
+        $list = \imap_getmailboxes($mboxt, '{'.$this->mailhost.':'.$port.'}', '*');
324 324
 
325 325
         if (\is_array($list)) {
326 326
             foreach ($list as $key => $val) {
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
                 $nameRaw = $nameArr[\count($nameArr) - 1];
330 330
 
331 331
                 if (\stripos($nameRaw, 'sent') === false) {
332
-                    $mboxd = \imap_open('{' . $this->mailhost . ':' . $port . '}' . $nameRaw, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE);
332
+                    $mboxd = \imap_open('{'.$this->mailhost.':'.$port.'}'.$nameRaw, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE);
333 333
                     $messages = \imap_sort($mboxd, SORTDATE, 0);
334 334
 
335 335
                     foreach ($messages as $message) {
@@ -405,19 +405,19 @@  discard block
 block discarded – undo
405 405
         if (\trim($mailbox) === '') {
406 406
             // this is a critical error with either the mailbox name blank or an invalid mailbox name
407 407
             // need to stop processing and exit at this point
408
-            echo 'Invalid mailbox name for move operation. Cannot continue: ' . $mailbox . "<br />\n";
408
+            echo 'Invalid mailbox name for move operation. Cannot continue: '.$mailbox."<br />\n";
409 409
             exit();
410 410
         }
411 411
 
412
-        $port = $this->port . '/' . $this->service . '/' . $this->serviceOption;
412
+        $port = $this->port.'/'.$this->service.'/'.$this->serviceOption;
413 413
         /** @noinspection PhpUsageOfSilenceOperatorInspection */
414
-        $mbox = @\imap_open('{' . $this->mailhost . ':' . $port . '}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
414
+        $mbox = @\imap_open('{'.$this->mailhost.':'.$port.'}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
415 415
 
416 416
         if ($mbox === false) {
417 417
             return false;
418 418
         }
419 419
 
420
-        $list = \imap_getmailboxes($mbox, '{' . $this->mailhost . ':' . $port . '}', '*');
420
+        $list = \imap_getmailboxes($mbox, '{'.$this->mailhost.':'.$port.'}', '*');
421 421
         $mailboxFound = false;
422 422
 
423 423
         if (\is_array($list)) {
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 
433 433
             if ($mailboxFound === false && $create) {
434 434
                 /** @noinspection PhpUsageOfSilenceOperatorInspection */
435
-                @\imap_createmailbox($mbox, \imap_utf7_encode('{' . $this->mailhost . ':' . $port . '}' . $mailbox));
435
+                @\imap_createmailbox($mbox, \imap_utf7_encode('{'.$this->mailhost.':'.$port.'}'.$mailbox));
436 436
                 /** @noinspection UnusedFunctionResultInspection */
437 437
                 \imap_errors();
438 438
                 /** @noinspection UnusedFunctionResultInspection */
@@ -478,13 +478,13 @@  discard block
 block discarded – undo
478 478
         }
479 479
 
480 480
         if (!$this->mailboxLink) {
481
-            $this->errorMessage = 'Cannot open the mailbox file to ' . $filePath . $this->bmhNewLine . 'Error MSG: ' . \imap_last_error();
481
+            $this->errorMessage = 'Cannot open the mailbox file to '.$filePath.$this->bmhNewLine.'Error MSG: '.\imap_last_error();
482 482
             $this->output();
483 483
 
484 484
             return false;
485 485
         }
486 486
 
487
-        $this->output('Opened ' . $filePath);
487
+        $this->output('Opened '.$filePath);
488 488
 
489 489
         return true;
490 490
     }
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
     {
499 499
         // before starting the processing, let's check the delete flag and do global deletes if true
500 500
         if (\trim($this->deleteMsgDate) !== '') {
501
-            echo 'processing global delete based on date of ' . $this->deleteMsgDate . '<br />';
501
+            echo 'processing global delete based on date of '.$this->deleteMsgDate.'<br />';
502 502
             $this->globalDelete();
503 503
         }
504 504
 
@@ -508,24 +508,24 @@  discard block
 block discarded – undo
508 508
             $this->moveHard = false;
509 509
         }
510 510
 
511
-        $port = $this->port . '/' . $this->service . '/' . $this->serviceOption;
511
+        $port = $this->port.'/'.$this->service.'/'.$this->serviceOption;
512 512
 
513 513
         \set_time_limit(self::SECONDS_TIMEOUT);
514 514
 
515 515
         if (!$this->testMode) {
516
-            $this->mailboxLink = \imap_open('{' . $this->mailhost . ':' . $port . '}' . $this->boxname, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE);
516
+            $this->mailboxLink = \imap_open('{'.$this->mailhost.':'.$port.'}'.$this->boxname, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE);
517 517
         } else {
518
-            $this->mailboxLink = \imap_open('{' . $this->mailhost . ':' . $port . '}' . $this->boxname, $this->mailboxUserName, $this->mailboxPassword, OP_READONLY);
518
+            $this->mailboxLink = \imap_open('{'.$this->mailhost.':'.$port.'}'.$this->boxname, $this->mailboxUserName, $this->mailboxPassword, OP_READONLY);
519 519
         }
520 520
 
521 521
         if (!$this->mailboxLink) {
522
-            $this->errorMessage = 'Cannot create ' . $this->service . ' connection to ' . $this->mailhost . $this->bmhNewLine . 'Error MSG: ' . \imap_last_error();
522
+            $this->errorMessage = 'Cannot create '.$this->service.' connection to '.$this->mailhost.$this->bmhNewLine.'Error MSG: '.\imap_last_error();
523 523
             $this->output();
524 524
 
525 525
             return false;
526 526
         }
527 527
 
528
-        $this->output('Connected to: ' . $this->mailhost . ' (' . $this->mailboxUserName . ')');
528
+        $this->output('Connected to: '.$this->mailhost.' ('.$this->mailboxUserName.')');
529 529
 
530 530
         return true;
531 531
     }
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
     {
541 541
         if ($this->verbose >= $verboseLevel) {
542 542
             if ($msg) {
543
-                echo $msg . $this->bmhNewLine;
543
+                echo $msg.$this->bmhNewLine;
544 544
             } else {
545
-                echo $this->errorMessage . $this->bmhNewLine;
545
+                echo $this->errorMessage.$this->bmhNewLine;
546 546
             }
547 547
         }
548 548
     }
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
                     break;
629 629
 
630 630
                 default: // un-support Content-type
631
-                    $this->output('Msg #' . $pos . ' is unsupported Content-Type:' . $structure->type, self::VERBOSE_REPORT);
631
+                    $this->output('Msg #'.$pos.' is unsupported Content-Type:'.$structure->type, self::VERBOSE_REPORT);
632 632
 
633 633
                     return false;
634 634
             }
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
             }
676 676
 
677 677
             if ($this->testMode) {
678
-                $this->output('Match: ' . $ruleNumber . ':' . $ruleCategory . '; ' . $bounceType . '; ' . $email);
678
+                $this->output('Match: '.$ruleNumber.':'.$ruleCategory.'; '.$bounceType.'; '.$email);
679 679
             } else {
680 680
                 // code below will use the Callback function, but return no value
681 681
                 $params = [
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
         } else {
701 701
             // match rule, do bounce action
702 702
             if ($this->testMode) {
703
-                $this->output('Match: ' . $ruleNumber . ':' . $ruleCategory . '; ' . $bounceType . '; ' . $email);
703
+                $this->output('Match: '.$ruleNumber.':'.$ruleCategory.'; '.$bounceType.'; '.$email);
704 704
 
705 705
                 return true;
706 706
             }
@@ -766,12 +766,12 @@  discard block
 block discarded – undo
766 766
         $unprocessedCount = 0;
767 767
         $deletedCount = 0;
768 768
         $movedCount = 0;
769
-        $this->output('Total: ' . $totalCount . ' messages ');
769
+        $this->output('Total: '.$totalCount.' messages ');
770 770
 
771 771
         // process maximum number of messages
772 772
         if ($fetchedCount > $this->maxMessages) {
773 773
             $fetchedCount = $this->maxMessages;
774
-            $this->output('Processing first ' . $fetchedCount . ' messages ');
774
+            $this->output('Processing first '.$fetchedCount.' messages ');
775 775
         }
776 776
 
777 777
         if ($this->testMode) {
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
                     $processedResult = $this->processBounce($x, 'DSN', $totalCount);
814 814
                 } else {
815 815
                     // not standard DSN msg
816
-                    $this->output('Msg #' . $x . ' is not a standard DSN message', self::VERBOSE_REPORT);
816
+                    $this->output('Msg #'.$x.' is not a standard DSN message', self::VERBOSE_REPORT);
817 817
 
818 818
                     if ($this->debugBodyRule) {
819 819
                         if ($structure->ifdescription) {
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
                         $processedResult = $this->processBounce($x, 'DSN', $totalCount);
840 840
                     } else {
841 841
                         // not standard DSN msg
842
-                        $this->output('Msg #' . $x . ' is not a standard DSN message', self::VERBOSE_REPORT);
842
+                        $this->output('Msg #'.$x.' is not a standard DSN message', self::VERBOSE_REPORT);
843 843
 
844 844
                         if ($this->debugBodyRule) {
845 845
                             $this->output("  Content-Type : {$match[1]}", self::VERBOSE_DEBUG);
@@ -849,10 +849,10 @@  discard block
 block discarded – undo
849 849
                     }
850 850
                 } else {
851 851
                     // didn't get content-type header
852
-                    $this->output('Msg #' . $x . ' is not a well-formatted MIME mail, missing Content-Type', self::VERBOSE_REPORT);
852
+                    $this->output('Msg #'.$x.' is not a well-formatted MIME mail, missing Content-Type', self::VERBOSE_REPORT);
853 853
 
854 854
                     if ($this->debugBodyRule) {
855
-                        $this->output('  Headers: ' . $this->bmhNewLine . $header . $this->bmhNewLine, self::VERBOSE_DEBUG);
855
+                        $this->output('  Headers: '.$this->bmhNewLine.$header.$this->bmhNewLine, self::VERBOSE_DEBUG);
856 856
                     }
857 857
 
858 858
                     $processedResult = $this->processBounce($x, 'BODY', $totalCount);
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
                     // move the message
884 884
                     if (!$this->testMode) {
885 885
                         /** @noinspection PhpUsageOfSilenceOperatorInspection */
886
-                        @\imap_mail_move($this->mailboxLink, (string) $x, $this->hardMailbox);
886
+                        @\imap_mail_move($this->mailboxLink, (string)$x, $this->hardMailbox);
887 887
                     }
888 888
 
889 889
                     $moveFlag[$x] = true;
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
                     // move the message
898 898
                     if (!$this->testMode) {
899 899
                         /** @noinspection PhpUsageOfSilenceOperatorInspection */
900
-                        @\imap_mail_move($this->mailboxLink, (string) $x, $this->softMailbox);
900
+                        @\imap_mail_move($this->mailboxLink, (string)$x, $this->softMailbox);
901 901
                     }
902 902
 
903 903
                     $moveFlag[$x] = true;
@@ -921,25 +921,25 @@  discard block
 block discarded – undo
921 921
                 $this->mailboxExist($this->unprocessedBox);
922 922
                 // move the message
923 923
                 /** @noinspection PhpUsageOfSilenceOperatorInspection */
924
-                @\imap_mail_move($this->mailboxLink, (string) $x, $this->unprocessedBox);
924
+                @\imap_mail_move($this->mailboxLink, (string)$x, $this->unprocessedBox);
925 925
                 $moveFlag[$x] = true;
926 926
             }
927 927
 
928 928
             \flush();
929 929
         }
930 930
 
931
-        $this->output($this->bmhNewLine . 'Closing mailbox, and purging messages');
931
+        $this->output($this->bmhNewLine.'Closing mailbox, and purging messages');
932 932
 
933 933
         /** @noinspection PhpUsageOfSilenceOperatorInspection */
934 934
         @\imap_expunge($this->mailboxLink);
935 935
         /** @noinspection PhpUsageOfSilenceOperatorInspection */
936 936
         @\imap_close($this->mailboxLink);
937 937
 
938
-        $this->output('Read: ' . $fetchedCount . ' messages');
939
-        $this->output($processedCount . ' action taken');
940
-        $this->output($unprocessedCount . ' no action taken');
941
-        $this->output($deletedCount . ' messages deleted');
942
-        $this->output($movedCount . ' messages moved');
938
+        $this->output('Read: '.$fetchedCount.' messages');
939
+        $this->output($processedCount.' action taken');
940
+        $this->output($unprocessedCount.' no action taken');
941
+        $this->output($deletedCount.' messages deleted');
942
+        $this->output($movedCount.' messages moved');
943 943
 
944 944
         return true;
945 945
     }
Please login to merge, or discard this patch.