Passed
Pull Request — master (#19)
by Kris
02:09
created
src/CheckBlockTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
             self::printResult(Console::pad('   Reported addresses:', 23), $nbReports, 'lightyellow');
66 66
             $numberDiplayedReports = 0;
67 67
                
68
-            foreach ($response->data->reportedAddress as $report){
68
+            foreach ($response->data->reportedAddress as $report) {
69 69
                 $score = empty($report->abuseConfidenceScore) ? 0 : $report->abuseConfidenceScore;
70 70
                 $defaultColor = self::getScoreColor($score); // color based on score
71 71
       
72 72
                 $line  = Console::text('   →', $defaultColor);
73 73
                 $line .= self::printResult(' IP: ', $report->ipAddress, $defaultColor, '', false);
74
-                $line .= self::printResult(' Country: ', $report->countryCode , $defaultColor, '', false);
74
+                $line .= self::printResult(' Country: ', $report->countryCode, $defaultColor, '', false);
75 75
                 $line .= Console::text(' | Confidence score: ', 'white');
76 76
                 $line .= self::getScoreBadge($score);
77 77
                 $line .= self::printResult(' Total reports: ', $report->numReports, $defaultColor, '', false);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                     $line .= Console::text($numberDiplayedReports, 'lightyellow');
87 87
                     $line .= Console::text('/', 'white');
88 88
                     $line .= Console::text($nbReports, 'lightyellow');
89
-                    $line .= Console::text($numberDiplayedReports > 1 ? ' IPs displayed)': ' IP displayed)', 'white');
89
+                    $line .= Console::text($numberDiplayedReports > 1 ? ' IPs displayed)' : ' IP displayed)', 'white');
90 90
                     Console::log($line);
91 91
                     break;
92 92
                 }
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
       
95 95
         } else {
96 96
             // no reports
97
-            $day = $maxAge > 1 ? 'in last '. $maxAge . ' days': ' today';
98
-            Console::log( Console::text('    ✓', 'green') . Console::text(' No IP reported ' . $day));
97
+            $day = $maxAge > 1 ? 'in last '.$maxAge.' days' : ' today';
98
+            Console::log(Console::text('    ✓', 'green').Console::text(' No IP reported '.$day));
99 99
         }
100 100
     }   
101 101
 }
102 102
\ No newline at end of file
Please login to merge, or discard this patch.
src/CheckTrait.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                             
172 172
         $line  = Console::text('    →', $defaultColor);
173 173
         $line .= self::printResult(' reported at: ', self::getDate($report->reportedAt), $defaultColor, '', false);
174
-  //    $line .= self::printResult(' by user: ', $report->reporterId, $defaultColor, '', false);
174
+    //    $line .= self::printResult(' by user: ', $report->reporterId, $defaultColor, '', false);
175 175
         if (isset($report->reporterCountryCode) && isset($report->reporterCountryName)){
176 176
             $line .= Console::text(' from: ', 'white');
177 177
             $line .= self::printResult('', $report->reporterCountryCode, $defaultColor, '', false);
@@ -206,5 +206,5 @@  discard block
 block discarded – undo
206 206
             }
207 207
         }
208 208
         return $categories;                          
209
-   }    
209
+    }    
210 210
 }
211 211
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     protected static function printCheckScore(object $response): void
41 41
     {
42 42
         $score = empty($response->data->abuseConfidenceScore) ? 0 : $response->data->abuseConfidenceScore;
43
-        $line = Console::text(Console::pad('   Confidence score:', 23), 'white') . self::getScoreBadge($score);
43
+        $line = Console::text(Console::pad('   Confidence score:', 23), 'white').self::getScoreBadge($score);
44 44
         Console::log($line);
45 45
     }
46 46
 
@@ -59,26 +59,26 @@  discard block
 block discarded – undo
59 59
         //  self::printResult('   isPublic', $response->data->isPublic, $defaultColor);
60 60
         //  self::printResult('   ipVersion', $response->data->ipVersion, $defaultColor);
61 61
  
62
-        $line = self::printResult(Console::pad('   Whitelisted:', 23), $response->data->isWhitelisted ? 'true': 'false', $color, '', false);
62
+        $line = self::printResult(Console::pad('   Whitelisted:', 23), $response->data->isWhitelisted ? 'true' : 'false', $color, '', false);
63 63
         $line .= $response->data->isWhitelisted ? Console::text(' ★', 'green') : ''; 
64 64
         Console::log($line);
65 65
        
66 66
         self::printResult(Console::pad('   Country code:', 23), $response->data->countryCode, $color);
67 67
         
68
-        if (!empty($response->data->countryName)){
68
+        if (!empty($response->data->countryName)) {
69 69
             self::printResult(Console::pad('   Country name:', 23), $response->data->countryName, $color);
70 70
         }
71 71
 
72 72
         self::printResult(Console::pad('   ISP:', 23), $response->data->isp, $color);
73 73
 
74
-        if ($response->data->usageType){
74
+        if ($response->data->usageType) {
75 75
             $line = self::printResult(Console::pad('   Usage type:', 23), $response->data->usageType, $color, '', false);
76 76
             $line .= $response->data->usageType === 'Reserved' ? Console::text(' ◆', 'green') : '';
77 77
             Console::log($line);
78 78
         }
79 79
 
80 80
         $hostames = implode(', ', array_filter($response->data->hostnames)) ?? null;
81
-        if (!empty($hostames)){
81
+        if (!empty($hostames)) {
82 82
             self::printResult(Console::pad('   Hostname(s):', 23), $hostames, $color);
83 83
         }
84 84
 
@@ -100,19 +100,19 @@  discard block
 block discarded – undo
100 100
     {
101 101
         $nbReport = $response->data->totalReports && is_numeric($response->data->totalReports) ? intval($response->data->totalReports) : 0;
102 102
         
103
-        if ($nbReport > 0 ){
103
+        if ($nbReport > 0) {
104 104
             $line  = self::printResult(Console::pad('   Total reports:', 23), $nbReport, $color, '', false);
105 105
             $line .= self::printResult(' from ', $response->data->numDistinctUsers, $color, '', false);
106
-            $line .= Console::text($nbReport > 0 ? ' distinct users': ' user', 'white');
106
+            $line .= Console::text($nbReport > 0 ? ' distinct users' : ' user', 'white');
107 107
             Console::log($line);
108 108
 
109 109
         } else {
110 110
             // no reports
111
-            $day = $maxAge > 1 ? 'in last '. $maxAge . ' days': ' today';
112
-            Console::log( Console::text('   ✓', 'green') . Console::text(' Not reported ' . $day));
111
+            $day = $maxAge > 1 ? 'in last '.$maxAge.' days' : ' today';
112
+            Console::log(Console::text('   ✓', 'green').Console::text(' Not reported '.$day));
113 113
         }
114 114
         
115
-        if (!empty($response->data->lastReportedAt)){
115
+        if (!empty($response->data->lastReportedAt)) {
116 116
             self::printResult(Console::pad('   Last reported at:', 23), self::getDate($response->data->lastReportedAt), $color);
117 117
         }
118 118
     }
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
     {
133 133
         $nbLastReports = isset($response->data->reports) ? count($response->data->reports) : 0;
134 134
             
135
-        if ($nbLastReports > 0){
135
+        if ($nbLastReports > 0) {
136 136
             Console::log('   Last reports:', 'white');
137 137
             $numberDiplayedReports = 0;
138 138
             $defaultColor = 'lightyellow'; // reset color for last reports
139 139
         
140
-            foreach ($response->data->reports as $report){
140
+            foreach ($response->data->reports as $report) {
141 141
                 self::printLastReport($report);
142 142
                 $numberDiplayedReports++;
143 143
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
                     $line .= Console::text($numberDiplayedReports, $defaultColor);
147 147
                     $line .= Console::text('/', 'white');
148 148
                     $line .= Console::text($nbLastReports, $defaultColor);
149
-                    $line .= Console::text($numberDiplayedReports > 1 ? ' reports displayed)': ' report displayed)', 'white');
149
+                    $line .= Console::text($numberDiplayedReports > 1 ? ' reports displayed)' : ' report displayed)', 'white');
150 150
                     Console::log($line);
151 151
                     break;
152 152
                 }
@@ -171,15 +171,15 @@  discard block
 block discarded – undo
171 171
         $line  = Console::text('    →', $defaultColor);
172 172
         $line .= self::printResult(' reported at: ', self::getDate($report->reportedAt), $defaultColor, '', false);
173 173
   //    $line .= self::printResult(' by user: ', $report->reporterId, $defaultColor, '', false);
174
-        if (isset($report->reporterCountryCode) && isset($report->reporterCountryName)){
174
+        if (isset($report->reporterCountryCode) && isset($report->reporterCountryName)) {
175 175
             $line .= Console::text(' from: ', 'white');
176 176
             $line .= self::printResult('', $report->reporterCountryCode, $defaultColor, '', false);
177 177
             $line .= Console::text(' - ', 'white');
178 178
             $line .= self::printResult('', $report->reporterCountryName, $defaultColor, '', false);
179 179
         }
180
-        $line .= Console::text(' with categor' .  (count($categories) > 1 ? "ies: " : "y: "), 'white');
180
+        $line .= Console::text(' with categor'.(count($categories) > 1 ? "ies: " : "y: "), 'white');
181 181
         foreach ($categories as $key => $cat) {
182
-            $line .= Console::text($key==0 ? '' : ',' , 'white') . Console::text($cat, $defaultColor);
182
+            $line .= Console::text($key == 0 ? '' : ',', 'white').Console::text($cat, $defaultColor);
183 183
         }
184 184
         Console::log($line);
185 185
     }  
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     private static function getLastReportsCategories(object $report): array
197 197
     {
198 198
         $categories = [];
199
-        foreach (array_filter($report->categories) as $catId){
199
+        foreach (array_filter($report->categories) as $catId) {
200 200
             $cat = ApiHandler::getCategoryNameById(strval($catId));
201 201
             if ($cat !== false) {
202 202
                 $categories[] = $cat;
Please login to merge, or discard this patch.
src/ShellErrorHandler.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@
 block discarded – undo
171 171
      */
172 172
     protected static function getNumericParameter(array $arguments, string $shortArg, string $longArg, int $defaultValue): int
173 173
     {
174
-         if (self::inArguments($arguments,$shortArg, $longArg)){
174
+            if (self::inArguments($arguments,$shortArg, $longArg)){
175 175
             $val = self::getArgumentValue($arguments,$shortArg, $longArg);
176 176
 
177 177
             if (!is_numeric($val)){
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
      */
57 57
     private static function parseErrors(?object $response = null): bool
58 58
     {
59
-        if (isset($response) && isset($response->errors)){
60
-            switch (self::$outputFormat){
59
+        if (isset($response) && isset($response->errors)) {
60
+            switch (self::$outputFormat) {
61 61
                 case self::OUTPUT_DEFAULT:
62 62
                     self::printFormattedErrors($response);
63 63
                     break;
@@ -86,24 +86,24 @@  discard block
 block discarded – undo
86 86
     protected static function printFormattedErrors(object $response): void
87 87
     {
88 88
         // top error badge    
89
-        Console::log('  ' .   Console::text(' ERROR ','white', 'red'));
89
+        Console::log('  '.Console::text(' ERROR ', 'white', 'red'));
90 90
 
91 91
         $num = 0;
92 92
         // errors is an array, could have more than one error..
93
-        foreach ($response->errors as $err){
93
+        foreach ($response->errors as $err) {
94 94
             $num++;
95 95
 
96
-            Console::log(Console::text('   ✗', 'red') .  self::printResult(' Number:    ', $num, 'lightyellow','', false));
97
-            self::printResult('     Status:    ', $err->status ?? null, 'lightyellow','');    
96
+            Console::log(Console::text('   ✗', 'red').self::printResult(' Number:    ', $num, 'lightyellow', '', false));
97
+            self::printResult('     Status:    ', $err->status ?? null, 'lightyellow', '');    
98 98
             
99
-            if (!empty($err->source) && !empty($err->source->parameter)){
99
+            if (!empty($err->source) && !empty($err->source->parameter)) {
100 100
                 self::printResult('     Parameter: ', $err->source->parameter, 'lightyellow');    
101 101
             }
102 102
             self::printResult('     Title:     ', $err->title ?? null, 'lightyellow');    
103 103
             self::printResult('     Detail:    ', $err->detail ?? null, 'lightyellow');    
104 104
 
105 105
             // separate errors
106
-            if (count($response->errors) > 1){
106
+            if (count($response->errors) > 1) {
107 107
                 Console::log('   ---');
108 108
             }
109 109
         }
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
     {
124 124
         if (self::isDefaultOuput()) {
125 125
             // ✗
126
-            Console::log('  ' .   Console::text(' ERROR ','white', 'red'));
126
+            Console::log('  '.Console::text(' ERROR ', 'white', 'red'));
127 127
             Console::log(
128
-                Console::text('   ✗', 'red') . 
129
-                Console::text(' Detail:    ', 'white') . 
130
-                Console::text($error, 'lightyellow') . 
128
+                Console::text('   ✗', 'red'). 
129
+                Console::text(' Detail:    ', 'white'). 
130
+                Console::text($error, 'lightyellow'). 
131 131
                 Console::text('', 'white')
132 132
             );    
133 133
             Console::log();
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      */
148 148
     protected static function validate(bool $condition, string $message, bool $print = true): void
149 149
     {
150
-        if ( !$condition ){
150
+        if (!$condition) {
151 151
             if ($print && self::isDefaultOuput()) {
152 152
                 Console::log();
153 153
                 self::error($message);
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
      */
172 172
     protected static function getNumericParameter(array $arguments, string $shortArg, string $longArg, int $defaultValue): int
173 173
     {
174
-         if (self::inArguments($arguments,$shortArg, $longArg)){
175
-            $val = self::getArgumentValue($arguments,$shortArg, $longArg);
174
+         if (self::inArguments($arguments, $shortArg, $longArg)) {
175
+            $val = self::getArgumentValue($arguments, $shortArg, $longArg);
176 176
 
177
-            if (!is_numeric($val)){
177
+            if (!is_numeric($val)) {
178 178
                 self::error("Invalid parameter: $longArg must be a numeric value.");
179 179
                 self::printFooter();
180 180
                 Program::exit(1);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      */
196 196
     protected static function printPlainTextErrors(object $response): void
197 197
     {
198
-        foreach ($response->errors as $err){
198
+        foreach ($response->errors as $err) {
199 199
             $text = 'Error: ';
200 200
             $text .= self::getErrorDetail($err, 'title');
201 201
             $text .= self::getErrorDetail($err, 'statuts');
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
      */
220 220
     private static function getErrorDetail(object $error, string $field, ?string $parent = null): string
221 221
     {
222
-        if (!empty($parent)){
223
-            return  !empty($error->$parent) && !empty($error->$parent->$field) ? ' ' . $field . ': ' . $error->$parent->$field : '';
222
+        if (!empty($parent)) {
223
+            return  !empty($error->$parent) && !empty($error->$parent->$field) ? ' '.$field.': '.$error->$parent->$field : '';
224 224
         }
225 225
 
226
-        return !empty($error->$field) ? ' ' . $field . ': ' . $error->$field : '';
226
+        return !empty($error->$field) ? ' '.$field.': '.$error->$field : '';
227 227
     }
228 228
 
229 229
     /**
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     protected static function checkForEmpty(?object $response = null): bool
239 239
     {
240 240
         // check for empty response ?
241
-        if ( empty($response) || empty($response->data) ){
241
+        if (empty($response) || empty($response->data)) {
242 242
             self::error('An unexpected error occurred.');
243 243
             return true;
244 244
         }
Please login to merge, or discard this patch.
src/UtilsTrait.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     protected static function inArguments(array $arguments, string $shortArg, string $longArg): bool
92 92
     {
93
-          return array_key_exists($shortArg, $arguments) || array_key_exists($longArg, $arguments);
93
+            return array_key_exists($shortArg, $arguments) || array_key_exists($longArg, $arguments);
94 94
     }
95 95
 
96 96
     /** 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @param string    $filePath       The file's full path
102 102
      * @param bool      $throwError     Throw error on true or silent process. Default is true
103 103
      *  
104
-	 * @return object|null 
104
+     * @return object|null 
105 105
      * @throws \Exception
106 106
      * @throws \LogicException
107 107
      */
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
     {
110 110
         // check file exists
111 111
         if (!file_exists($filePath) || !is_file($filePath)){
112
-           if ($throwError) {
112
+            if ($throwError) {
113 113
                 throw new \Exception('Config file not found');
114
-           }
115
-           return null;  
114
+            }
115
+            return null;  
116 116
         }
117 117
 
118 118
         // get and parse content
Please login to merge, or discard this patch.
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     protected static function getScoreColor($score): string
56 56
     {
57 57
         $score = intval($score);
58
-        return $score > 50 ? 'lightred' : ($score > 0 ? 'yellow' : 'green') ;
58
+        return $score > 50 ? 'lightred' : ($score > 0 ? 'yellow' : 'green');
59 59
     }
60 60
 
61 61
    
@@ -73,8 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     protected static function getArgumentValue(array $arguments, string $shortArg, string $longArg): string
75 75
     {
76
-        return (array_key_exists($shortArg, $arguments) ? $arguments[$shortArg] : 
77
-               (array_key_exists($longArg, $arguments) ? $arguments[$longArg]  : ''));
76
+        return (array_key_exists($shortArg, $arguments) ? $arguments[$shortArg] : (array_key_exists($longArg, $arguments) ? $arguments[$longArg] : ''));
78 77
     }
79 78
 
80 79
     /**
@@ -108,7 +107,7 @@  discard block
 block discarded – undo
108 107
     protected static function loadJsonFile(string $filePath, bool $throwError = true): ?object
109 108
     {
110 109
         // check file exists
111
-        if (!file_exists($filePath) || !is_file($filePath)){
110
+        if (!file_exists($filePath) || !is_file($filePath)) {
112 111
            if ($throwError) {
113 112
                 throw new \Exception('Config file not found');
114 113
            }
Please login to merge, or discard this patch.
src/AbuseIPDBClient.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -104,54 +104,54 @@
 block discarded – undo
104 104
 
105 105
         Console::log(' ' . Console::text('SYNOPSIS:', 'white', 'underline')); 
106 106
         Console::log(' ' . Console::text('    abuseipdb -C ') . 
107
-                           Console::text('IP', 'yellow') . 
108
-                           Console::text(' [-d ') . 
109
-                           Console::text('DAYS', 'yellow') . 
110
-                           Console::text('] [-v] [-l ') . 
111
-                           Console::text('LIMIT', 'yellow') . 
112
-                           Console::text('] [-o ') . 
113
-                           Console::text('FORMAT', 'yellow') . 
114
-                           Console::text(']')); 
107
+                            Console::text('IP', 'yellow') . 
108
+                            Console::text(' [-d ') . 
109
+                            Console::text('DAYS', 'yellow') . 
110
+                            Console::text('] [-v] [-l ') . 
111
+                            Console::text('LIMIT', 'yellow') . 
112
+                            Console::text('] [-o ') . 
113
+                            Console::text('FORMAT', 'yellow') . 
114
+                            Console::text(']')); 
115 115
 
116 116
         Console::log(' ' . Console::text('    abuseipdb -K ') . 
117
-                           Console::text('NETWORK', 'yellow') . 
118
-                           Console::text(' [-d ') . 
119
-                           Console::text('DAYS', 'yellow') . 
120
-                           Console::text('] [-o ') . 
121
-                           Console::text('FORMAT', 'yellow') . 
122
-                           Console::text(']')); 
117
+                            Console::text('NETWORK', 'yellow') . 
118
+                            Console::text(' [-d ') . 
119
+                            Console::text('DAYS', 'yellow') . 
120
+                            Console::text('] [-o ') . 
121
+                            Console::text('FORMAT', 'yellow') . 
122
+                            Console::text(']')); 
123 123
 
124 124
         Console::log(' ' . Console::text('    abuseipdb -R ') .
125
-                           Console::text('IP', 'yellow') . ' -c ' .
126
-                           Console::text('CATEGORIES', 'yellow') . ' -m ' .
127
-                           Console::text('MESSAGE', 'yellow') .
128
-                           Console::text(' [-o ') . 
129
-                           Console::text('FORMAT', 'yellow') . 
130
-                           Console::text(']')); 
125
+                            Console::text('IP', 'yellow') . ' -c ' .
126
+                            Console::text('CATEGORIES', 'yellow') . ' -m ' .
127
+                            Console::text('MESSAGE', 'yellow') .
128
+                            Console::text(' [-o ') . 
129
+                            Console::text('FORMAT', 'yellow') . 
130
+                            Console::text(']')); 
131 131
 
132 132
         Console::log(' ' . Console::text('    abuseipdb -V ') .
133
-                           Console::text('FILE', 'yellow') .
134
-                           Console::text(' [-o ') . 
135
-                           Console::text('FORMAT', 'yellow') . 
136
-                           Console::text(']')); 
133
+                            Console::text('FILE', 'yellow') .
134
+                            Console::text(' [-o ') . 
135
+                            Console::text('FORMAT', 'yellow') . 
136
+                            Console::text(']')); 
137 137
 
138 138
         Console::log(' ' . Console::text('    abuseipdb -E ') .
139
-                           Console::text('IP', 'yellow').
140
-                           Console::text(' [-o ') . 
141
-                           Console::text('FORMAT', 'yellow') . 
142
-                           Console::text(']')); 
139
+                            Console::text('IP', 'yellow').
140
+                            Console::text(' [-o ') . 
141
+                            Console::text('FORMAT', 'yellow') . 
142
+                            Console::text(']')); 
143 143
                            
144 144
         Console::log(' ' . Console::text('    abuseipdb -B ') . 
145
-                           Console::text('[-l ') . 
146
-                           Console::text('LIMIT', 'yellow') . 
147
-                           Console::text('] [-s ') . 
148
-                           Console::text('SCORE', 'yellow') . 
149
-                           Console::text('] [-o ') . 
150
-                           Console::text('FORMAT', 'yellow') . 
151
-                           Console::text(']')); 
145
+                            Console::text('[-l ') . 
146
+                            Console::text('LIMIT', 'yellow') . 
147
+                            Console::text('] [-s ') . 
148
+                            Console::text('SCORE', 'yellow') . 
149
+                            Console::text('] [-o ') . 
150
+                            Console::text('FORMAT', 'yellow') . 
151
+                            Console::text(']')); 
152 152
 
153 153
         Console::log(' ' . Console::text('    abuseipdb -S ' .
154
-                           Console::text('KEY', 'yellow')));
154
+                            Console::text('KEY', 'yellow')));
155 155
 
156 156
         Console::log(' ' . Console::text('    abuseipdb -L | -G | -h | --version'));
157 157
                            
Please login to merge, or discard this patch.
Spacing   +114 added lines, -115 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     {
49 49
         // required at least one valid argument
50 50
         self::$keyPath = $keyPath; 
51
-        self::validate( !empty($arguments), 'No valid arguments given. Run abuseipdb --help to get help.');
51
+        self::validate(!empty($arguments), 'No valid arguments given. Run abuseipdb --help to get help.');
52 52
         if (!self::parseCommand($arguments, $keyPath)) {
53 53
             self::error('Invalid arguments. Run abuseipdb --help to get help.');
54 54
             self::printFooter();
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
     {
70 70
         self::printTitle(Console::text('  ► Register API key ', 'darkgray'));
71 71
         
72
-        $key = self::getArgumentValue($arguments,'S', 'save-key');
72
+        $key = self::getArgumentValue($arguments, 'S', 'save-key');
73 73
         
74
-        if (empty($key)){
74
+        if (empty($key)) {
75 75
             self::error('Null or invalid key argument.');
76 76
             self::printFooter();
77 77
             Program::exit(1);
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 
80 80
         $data = json_encode(['api_key' => $key]);
81 81
        
82
-        if (file_put_contents(self::$keyPath, $data, LOCK_EX) === false){
82
+        if (file_put_contents(self::$keyPath, $data, LOCK_EX) === false) {
83 83
             self::error('An error occurred when writing config file. Make sure to give the appropriate permissions to the config directory.');
84 84
             self::printFooter();
85 85
             Program::exit(1);
86 86
         }
87
-        Console::log(Console::text('  ✓ ', 'green') . Console::text('Your config key file has been successfully created.', 'white'));
87
+        Console::log(Console::text('  ✓ ', 'green').Console::text('Your config key file has been successfully created.', 'white'));
88 88
         Console::log();   
89 89
         self::printFooter();
90 90
         Program::exit();
@@ -102,61 +102,61 @@  discard block
 block discarded – undo
102 102
     {
103 103
         self::printBanner();
104 104
 
105
-        Console::log(' ' . Console::text('SYNOPSIS:', 'white', 'underline')); 
106
-        Console::log(' ' . Console::text('    abuseipdb -C ') . 
107
-                           Console::text('IP', 'yellow') . 
108
-                           Console::text(' [-d ') . 
109
-                           Console::text('DAYS', 'yellow') . 
110
-                           Console::text('] [-v] [-l ') . 
111
-                           Console::text('LIMIT', 'yellow') . 
112
-                           Console::text('] [-o ') . 
113
-                           Console::text('FORMAT', 'yellow') . 
105
+        Console::log(' '.Console::text('SYNOPSIS:', 'white', 'underline')); 
106
+        Console::log(' '.Console::text('    abuseipdb -C '). 
107
+                           Console::text('IP', 'yellow'). 
108
+                           Console::text(' [-d '). 
109
+                           Console::text('DAYS', 'yellow'). 
110
+                           Console::text('] [-v] [-l '). 
111
+                           Console::text('LIMIT', 'yellow'). 
112
+                           Console::text('] [-o '). 
113
+                           Console::text('FORMAT', 'yellow'). 
114 114
                            Console::text(']')); 
115 115
 
116
-        Console::log(' ' . Console::text('    abuseipdb -K ') . 
117
-                           Console::text('NETWORK', 'yellow') . 
118
-                           Console::text(' [-d ') . 
119
-                           Console::text('DAYS', 'yellow') . 
120
-                           Console::text('] [-o ') . 
121
-                           Console::text('FORMAT', 'yellow') . 
116
+        Console::log(' '.Console::text('    abuseipdb -K '). 
117
+                           Console::text('NETWORK', 'yellow'). 
118
+                           Console::text(' [-d '). 
119
+                           Console::text('DAYS', 'yellow'). 
120
+                           Console::text('] [-o '). 
121
+                           Console::text('FORMAT', 'yellow'). 
122 122
                            Console::text(']')); 
123 123
 
124
-        Console::log(' ' . Console::text('    abuseipdb -R ') .
125
-                           Console::text('IP', 'yellow') . ' -c ' .
126
-                           Console::text('CATEGORIES', 'yellow') . ' -m ' .
127
-                           Console::text('MESSAGE', 'yellow') .
128
-                           Console::text(' [-o ') . 
129
-                           Console::text('FORMAT', 'yellow') . 
124
+        Console::log(' '.Console::text('    abuseipdb -R ').
125
+                           Console::text('IP', 'yellow').' -c '.
126
+                           Console::text('CATEGORIES', 'yellow').' -m '.
127
+                           Console::text('MESSAGE', 'yellow').
128
+                           Console::text(' [-o '). 
129
+                           Console::text('FORMAT', 'yellow'). 
130 130
                            Console::text(']')); 
131 131
 
132
-        Console::log(' ' . Console::text('    abuseipdb -V ') .
133
-                           Console::text('FILE', 'yellow') .
134
-                           Console::text(' [-o ') . 
135
-                           Console::text('FORMAT', 'yellow') . 
132
+        Console::log(' '.Console::text('    abuseipdb -V ').
133
+                           Console::text('FILE', 'yellow').
134
+                           Console::text(' [-o '). 
135
+                           Console::text('FORMAT', 'yellow'). 
136 136
                            Console::text(']')); 
137 137
 
138
-        Console::log(' ' . Console::text('    abuseipdb -E ') .
138
+        Console::log(' '.Console::text('    abuseipdb -E ').
139 139
                            Console::text('IP', 'yellow').
140
-                           Console::text(' [-o ') . 
141
-                           Console::text('FORMAT', 'yellow') . 
140
+                           Console::text(' [-o '). 
141
+                           Console::text('FORMAT', 'yellow'). 
142 142
                            Console::text(']')); 
143 143
                            
144
-        Console::log(' ' . Console::text('    abuseipdb -B ') . 
145
-                           Console::text('[-l ') . 
146
-                           Console::text('LIMIT', 'yellow') . 
147
-                           Console::text('] [-s ') . 
148
-                           Console::text('SCORE', 'yellow') . 
149
-                           Console::text('] [-o ') . 
150
-                           Console::text('FORMAT', 'yellow') . 
144
+        Console::log(' '.Console::text('    abuseipdb -B '). 
145
+                           Console::text('[-l '). 
146
+                           Console::text('LIMIT', 'yellow'). 
147
+                           Console::text('] [-s '). 
148
+                           Console::text('SCORE', 'yellow'). 
149
+                           Console::text('] [-o '). 
150
+                           Console::text('FORMAT', 'yellow'). 
151 151
                            Console::text(']')); 
152 152
 
153
-        Console::log(' ' . Console::text('    abuseipdb -S ' .
153
+        Console::log(' '.Console::text('    abuseipdb -S '.
154 154
                            Console::text('KEY', 'yellow')));
155 155
 
156
-        Console::log(' ' . Console::text('    abuseipdb -L | -G | -h | --version'));
156
+        Console::log(' '.Console::text('    abuseipdb -L | -G | -h | --version'));
157 157
                            
158 158
         Console::log();    
159
-        Console::log(' ' . Console::text('OPTIONS:', 'white', 'underline')); 
159
+        Console::log(' '.Console::text('OPTIONS:', 'white', 'underline')); 
160 160
         Console::log();
161 161
         Console::log(Console::text('   -h, --help', 'white')); 
162 162
         Console::log('       Prints the current help.', 'lightgray');
@@ -167,62 +167,62 @@  discard block
 block discarded – undo
167 167
         Console::log(Console::text('   -L, --list', 'white')); 
168 168
         Console::log('       Prints the list report categories.', 'lightgray');
169 169
         Console::log();    
170
-        Console::log(Console::text('   -C, --check ', 'white') . Console::text('IP', 'yellow', 'underline')); 
170
+        Console::log(Console::text('   -C, --check ', 'white').Console::text('IP', 'yellow', 'underline')); 
171 171
         Console::log('       Performs a check request for the given IP address. A valid IPv4 or IPv6 address is required.', 'lightgray');
172 172
         Console::log();    
173
-        Console::log(Console::text('   -K, --check-block ', 'white') . Console::text('NETWORK', 'yellow', 'underline')); 
173
+        Console::log(Console::text('   -K, --check-block ', 'white').Console::text('NETWORK', 'yellow', 'underline')); 
174 174
         Console::log('       Performs a check-block request for the given network. A valid subnet (v4 or v6) denoted with ', 'lightgray');
175 175
         Console::log('       CIDR notation is required.', 'lightgray');
176 176
         Console::log();    
177
-        Console::log(Console::text('   -d, --days ', 'white') . Console::text('DAYS', 'yellow', 'underline')); 
177
+        Console::log(Console::text('   -d, --days ', 'white').Console::text('DAYS', 'yellow', 'underline')); 
178 178
         Console::log('       For a check or check-block request, defines the maxAgeDays. Min is 1, max is 365, default is 30.', 'lightgray');
179 179
         Console::log();    
180
-        Console::log(Console::text('   -R, --report ', 'white') . Console::text('IP', 'yellow', 'underline')); 
180
+        Console::log(Console::text('   -R, --report ', 'white').Console::text('IP', 'yellow', 'underline')); 
181 181
         Console::log('       Performs a report request for the given IP address. A valid IPv4 or IPv6 address is required.', 'lightgray');
182 182
         Console::log();    
183
-        Console::log(Console::text('   -V, --bulk-report ', 'white') . Console::text('FILE', 'yellow', 'underline')); 
183
+        Console::log(Console::text('   -V, --bulk-report ', 'white').Console::text('FILE', 'yellow', 'underline')); 
184 184
         Console::log('       Performs a bulk-report request sending a csv file. A valid file name or full path is required.', 'lightgray');
185 185
         Console::log();    
186 186
         Console::log(Console::text('   -E, --clear ', 'white')); 
187 187
         Console::log('       Remove own reports for the given IP address. A valid IPv4 or IPv6 address is required.', 'lightgray');
188 188
         Console::log();
189
-        Console::log(Console::text('   -c, --categories ', 'white') . Console::text('CATEGORIES', 'yellow', 'underline')); 
189
+        Console::log(Console::text('   -c, --categories ', 'white').Console::text('CATEGORIES', 'yellow', 'underline')); 
190 190
         Console::log('       For a report request, defines the report category(ies). Categories must be separate by a comma.', 'lightgray');
191 191
         Console::log('       Some categories cannot be used alone. A category can be represented by its shortname or by its', 'lightgray');
192
-        Console::log(Console::text('       id. Use ','lightgray')  . Console::text('abuseipdb -L', 'white') . Console::text(' to print the categories list.','lightgray'));
192
+        Console::log(Console::text('       id. Use ', 'lightgray').Console::text('abuseipdb -L', 'white').Console::text(' to print the categories list.', 'lightgray'));
193 193
         Console::log();    
194
-        Console::log(Console::text('   -m, --message ', 'white') . Console::text('MESSAGE', 'yellow', 'underline')); 
194
+        Console::log(Console::text('   -m, --message ', 'white').Console::text('MESSAGE', 'yellow', 'underline')); 
195 195
         Console::log('       For a report request, defines the message to send with report. Message is required for all', 'lightgray');
196 196
         Console::log('       report requests.', 'lightgray');
197 197
         Console::log();
198 198
         Console::log(Console::text('   -B, --blacklist ', 'white')); 
199 199
         Console::log('       Performs a blacklist request. Default limit is 1000. This limit can ne changed with the', 'lightgray');
200
-        Console::log('       ' . Console::text('--limit', 'white') . Console::text(' parameter. ', 'lightgray'));
200
+        Console::log('       '.Console::text('--limit', 'white').Console::text(' parameter. ', 'lightgray'));
201 201
         Console::log();    
202
-        Console::log(Console::text('   -l, --limit ', 'white') . Console::text('LIMIT', 'yellow', 'underline')); 
202
+        Console::log(Console::text('   -l, --limit ', 'white').Console::text('LIMIT', 'yellow', 'underline')); 
203 203
         Console::log('       For a blacklist request, defines the limit.', 'lightgray');
204 204
         Console::log('       For a check request with verbose flag, sets the max number of last reports displayed. Default is 10', 'lightgray');
205 205
         Console::log('       For a check-block request, sets the max number of IPs displayed. Default is 0 (no limit).', 'lightgray');
206 206
         Console::log();    
207
-        Console::log(Console::text('   -o, --output ', 'white') . Console::text('FORMAT', 'yellow', 'underline')); 
207
+        Console::log(Console::text('   -o, --output ', 'white').Console::text('FORMAT', 'yellow', 'underline')); 
208 208
         Console::log('       Defines the output format for API requests. Default is a colorized report, possible formats are', 'lightgray');
209
-        Console::log('       '. Console::text('json', 'yellow', 'underline') . ' or ' . Console::text('plaintext', 'yellow', 'underline') . '. Plaintext option prints partial response (blacklist: IPs list, ');
209
+        Console::log('       '.Console::text('json', 'yellow', 'underline').' or '.Console::text('plaintext', 'yellow', 'underline').'. Plaintext option prints partial response (blacklist: IPs list, ');
210 210
         Console::log('       check or report: confidence score only, check-block: reported IPs list with confidence score, ', 'lightgray');
211 211
         Console::log('       bulk-report: number of saved reports, clear: number of deleted reports).', 'lightgray');
212 212
         Console::log();    
213
-        Console::log(Console::text('   -s, --score ', 'white'). Console::text('SCORE', 'yellow', 'underline')); 
213
+        Console::log(Console::text('   -s, --score ', 'white').Console::text('SCORE', 'yellow', 'underline')); 
214 214
         Console::log('       For a blacklist request, sets the confidence score minimum. The confidence minimum ', 'lightgray');
215 215
         Console::log('       must be between 25 and 100. This parameter is subscriber feature (not honored otherwise, allways 100).', 'lightgray');
216 216
         Console::log();    
217 217
         Console::log(Console::text('   -v, --verbose ', 'white')); 
218 218
         Console::log('       For a check request, display additional fields like the x last reports. This increases ', 'lightgray');
219 219
         Console::log(Console::text('       request time and response size. Max number of last reports displayed can be changed with the ', 'lightgray'));
220
-        Console::log('       ' . Console::text('--limit', 'white') . Console::text(' parameter. ', 'lightgray'));
220
+        Console::log('       '.Console::text('--limit', 'white').Console::text(' parameter. ', 'lightgray'));
221 221
         Console::log();    
222 222
         Console::log(Console::text('   --version', 'white')); 
223 223
         Console::log('       Prints the current version.', 'lightgray');
224 224
         Console::log(); 
225
-        Console::log(Console::text('   -S, --save-key ', 'white') . Console::text('KEY', 'yellow', 'underline')); 
225
+        Console::log(Console::text('   -S, --save-key ', 'white').Console::text('KEY', 'yellow', 'underline')); 
226 226
         Console::log('       Save the given API key in the configuration file. Requires writing permissions on the config directory. ', 'lightgray');
227 227
         Console::log(); 
228 228
     }
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 
242 242
         self::printTitle(Console::text('  ► Current configuration ', 'darkgray'));
243 243
         
244
-        Console::log(Console::text('  api_key:[', 'white') . Console::text($conf['apiKey'], 'green') . Console::text(']', 'white'));
244
+        Console::log(Console::text('  api_key:[', 'white').Console::text($conf['apiKey'], 'green').Console::text(']', 'white'));
245 245
         Console::log(Console::text('  self_ips:', 'white'));
246 246
         
247 247
         foreach ($conf['selfIps'] as $ip) {
248
-            Console::log(Console::text('    [', 'white') . Console::text($ip, 'green') . Console::text(']', 'white'));   
248
+            Console::log(Console::text('    [', 'white').Console::text($ip, 'green').Console::text(']', 'white'));   
249 249
         }
250 250
 
251 251
         Console::log();   
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 
267 267
         $categories = ApiHandler::getCategories();
268 268
         $rowHeaders = [
269
-            Console::text('ShortName',      'darkgray') => 15, 
270
-            Console::text('Id',             'darkgray') => 2, 
271
-            Console::text('Full name',      'darkgray') => 18,
272
-            Console::text('Can be alone?',  'darkgray') => 15
269
+            Console::text('ShortName', 'darkgray') => 15, 
270
+            Console::text('Id', 'darkgray') => 2, 
271
+            Console::text('Full name', 'darkgray') => 18,
272
+            Console::text('Can be alone?', 'darkgray') => 15
273 273
         ];
274 274
         Console::$verticalSeparator = '  ';
275 275
         Console::$verticalInnerSeparator = '  ';
@@ -279,17 +279,16 @@  discard block
 block discarded – undo
279 279
         
280 280
         foreach ($categories as $cat) {
281 281
             $id = Console::text($cat[1], 'white');
282
-            $standalone = $cat[3] ? Console::text('✓', 'green') . Console::text(' true ', 'lightgray') : 
283
-                                    Console::text('✗', 'red')   . Console::text(' false', 'darkgray');
284
-            $shortName =  Console::text($cat[0], 'white');
285
-            $fullName =   Console::text($cat[2], 'lightgray');
282
+            $standalone = $cat[3] ? Console::text('✓', 'green').Console::text(' true ', 'lightgray') : Console::text('✗', 'red').Console::text(' false', 'darkgray');
283
+            $shortName = Console::text($cat[0], 'white');
284
+            $fullName = Console::text($cat[2], 'lightgray');
286 285
 
287 286
             Console::log(
288 287
                 Console::TableRowStart().  
289
-                Console::TableRowCell( $shortName , 15).  
290
-                Console::TableRowCell( $id , 2, Console::ALIGN_CENTER).  
291
-                Console::TableRowCell( $fullName , 18).  
292
-                Console::TableRowCell( $standalone , 15,  Console::ALIGN_CENTER)  
288
+                Console::TableRowCell($shortName, 15).  
289
+                Console::TableRowCell($id, 2, Console::ALIGN_CENTER).  
290
+                Console::TableRowCell($fullName, 18).  
291
+                Console::TableRowCell($standalone, 15, Console::ALIGN_CENTER)  
293 292
             );
294 293
         }
295 294
         //Console::log(Console::tableRowSeparator($rowHeaders), 'darkgray');
@@ -308,11 +307,11 @@  discard block
 block discarded – undo
308 307
      */
309 308
     protected static function reportIP(array $arguments): void
310 309
     {
311
-        $ip      = self::getArgumentValue($arguments,'R', 'report');
312
-        $cats    = self::getArgumentValue($arguments,'c', 'categories');
313
-        $message = self::getArgumentValue($arguments,'m', 'message');
310
+        $ip      = self::getArgumentValue($arguments, 'R', 'report');
311
+        $cats    = self::getArgumentValue($arguments, 'c', 'categories');
312
+        $message = self::getArgumentValue($arguments, 'm', 'message');
314 313
         
315
-        self::printTitle(Console::text('  ► Report IP: ', 'darkgray') . Console::text(escapeshellcmd($ip), 'white'));
314
+        self::printTitle(Console::text('  ► Report IP: ', 'darkgray').Console::text(escapeshellcmd($ip), 'white'));
316 315
         self::printTempMessage();
317 316
 
318 317
         // Peforms request 
@@ -323,7 +322,7 @@  discard block
 block discarded – undo
323 322
         self::clearTempMessage();
324 323
         
325 324
         // check for errors / empty response
326
-        if (self::hasErrors($report)){
325
+        if (self::hasErrors($report)) {
327 326
             self::printFooter();
328 327
             Program::exit(1);
329 328
         }
@@ -332,14 +331,14 @@  discard block
 block discarded – undo
332 331
         $score = empty($report->data->abuseConfidenceScore) ? 0 : $report->data->abuseConfidenceScore;
333 332
         $scoreColor = self::getScoreColor($score);
334 333
 
335
-        switch (self::$outputFormat){
334
+        switch (self::$outputFormat) {
336 335
             case self::OUTPUT_JSON:
337 336
                 echo json_encode($report, JSON_PRETTY_PRINT);
338 337
                 break;
339 338
        
340 339
             case self::OUTPUT_DEFAULT:  
341 340
                 Console::log(
342
-                    Console::text('   ✓', 'green').Console::text(' IP: [', 'white') .
341
+                    Console::text('   ✓', 'green').Console::text(' IP: [', 'white').
343 342
                     Console::text($ip, $scoreColor).Console::text('] successfully reported', 'white')
344 343
                 );
345 344
                 Console::log(Console::text('     Confidence score: ', 'white').self::getScoreBadge($score));
@@ -365,26 +364,26 @@  discard block
 block discarded – undo
365 364
      */
366 365
     protected static function bulkReport(array $arguments): void
367 366
     {
368
-        $fileName = self::getArgumentValue($arguments,'V', 'bulk-report');
367
+        $fileName = self::getArgumentValue($arguments, 'V', 'bulk-report');
369 368
 
370
-        self::printTitle(Console::text('  ► Bulk report for file: ', 'darkgray') . Console::text(escapeshellcmd($fileName), 'white'));
369
+        self::printTitle(Console::text('  ► Bulk report for file: ', 'darkgray').Console::text(escapeshellcmd($fileName), 'white'));
371 370
         self::printTempMessage();
372 371
 
373 372
         // Peforms request 
374 373
         $timeStart = microtime(true);  
375 374
         $response = self::$api->bulkReport($fileName)->getObject();     
376 375
         $timeEnd = microtime(true);      
377
-        $time = $timeEnd - $timeStart;  // request time
376
+        $time = $timeEnd - $timeStart; // request time
378 377
         self::clearTempMessage();
379 378
 
380 379
         // check for errors / empty response
381
-        if (self::hasErrors($response)){
380
+        if (self::hasErrors($response)) {
382 381
             self::printFooter();
383 382
             Program::exit(1);
384 383
         }
385 384
 
386 385
         // ✓ Done
387
-        switch (self::$outputFormat){
386
+        switch (self::$outputFormat) {
388 387
             case self::OUTPUT_JSON:
389 388
                 echo json_encode($response, JSON_PRETTY_PRINT);
390 389
                 break;
@@ -399,7 +398,7 @@  discard block
 block discarded – undo
399 398
 
400 399
             case self::OUTPUT_PLAINTEXT:
401 400
                 $nbSavedReports = isset($response->data->savedReports) ? $response->data->savedReports : 0;
402
-                echo $nbSavedReports . PHP_EOL;
401
+                echo $nbSavedReports.PHP_EOL;
403 402
                 break;
404 403
 
405 404
         }
@@ -416,8 +415,8 @@  discard block
 block discarded – undo
416 415
      */
417 416
     protected static function clearIP(array $arguments): void
418 417
     {
419
-        $ip = self::getArgumentValue($arguments,'E', 'clear');
420
-        self::printTitle(Console::text('  ► Clear reports for IP: ', 'darkgray') . Console::text(escapeshellcmd($ip), 'white'));
418
+        $ip = self::getArgumentValue($arguments, 'E', 'clear');
419
+        self::printTitle(Console::text('  ► Clear reports for IP: ', 'darkgray').Console::text(escapeshellcmd($ip), 'white'));
421 420
 
422 421
         // Peforms request 
423 422
         self::printTempMessage();
@@ -428,22 +427,22 @@  discard block
 block discarded – undo
428 427
         self::clearTempMessage();
429 428
 
430 429
         // check for errors / empty response
431
-        if (self::hasErrors($response)){
430
+        if (self::hasErrors($response)) {
432 431
             self::printFooter($time);
433 432
             Program::exit(1);
434 433
         }
435 434
         
436 435
         // ✓ Done: print deleted report number 
437
-        switch (self::$outputFormat){
436
+        switch (self::$outputFormat) {
438 437
             case self::OUTPUT_JSON:
439 438
                 echo json_encode($response, JSON_PRETTY_PRINT);
440 439
                 break;
441 440
        
442 441
             case self::OUTPUT_DEFAULT:  
443 442
                 Console::log(
444
-                    Console::text('   ✓', 'green') . 
445
-                    Console::text(' Successfull clear request for IP: [', 'white') .
446
-                    Console::text($ip, 'lightyellow') .
443
+                    Console::text('   ✓', 'green'). 
444
+                    Console::text(' Successfull clear request for IP: [', 'white').
445
+                    Console::text($ip, 'lightyellow').
447 446
                     Console::text(']', 'white')
448 447
                 );
449 448
                 self::printResult('     Deleted reports: ', $response->data->numReportsDeleted ?? 0, 'lightyellow');
@@ -452,7 +451,7 @@  discard block
 block discarded – undo
452 451
                 break;
453 452
 
454 453
             case self::OUTPUT_PLAINTEXT:
455
-                echo ($response->data->numReportsDeleted ?? 0) . PHP_EOL;
454
+                echo ($response->data->numReportsDeleted ?? 0).PHP_EOL;
456 455
                 break;
457 456
 
458 457
         }
@@ -472,8 +471,8 @@  discard block
 block discarded – undo
472 471
         self::printTitle(Console::text('  ► Get Blacklist ', 'darkgray'));
473 472
 
474 473
         $plainText  = (self::$outputFormat === self::OUTPUT_PLAINTEXT); 
475
-        $limit      = self::getNumericParameter($arguments,'l', 'limit', 1000);
476
-        $scoreMin   = self::getNumericParameter($arguments,'s', 'score', 100);
474
+        $limit      = self::getNumericParameter($arguments, 'l', 'limit', 1000);
475
+        $scoreMin   = self::getNumericParameter($arguments, 's', 'score', 100);
477 476
         
478 477
         self::printTempMessage();
479 478
         
@@ -487,13 +486,13 @@  discard block
 block discarded – undo
487 486
     
488 487
         // response could be json on error, while plaintext flag is set
489 488
         $decodedResponse = $response->getObject();
490
-        if (self::hasErrors($decodedResponse, false)){
489
+        if (self::hasErrors($decodedResponse, false)) {
491 490
             self::printFooter($time);
492 491
             Program::exit(1);
493 492
         }
494 493
 
495 494
         // ✓ Done: print deleted report number 
496
-        switch (self::$outputFormat){
495
+        switch (self::$outputFormat) {
497 496
             case self::OUTPUT_JSON:
498 497
                 echo json_encode($decodedResponse, JSON_PRETTY_PRINT);
499 498
                 break;
@@ -502,7 +501,7 @@  discard block
 block discarded – undo
502 501
                  // print list
503 502
                 self::printResult('  List generated at: ', self::getDate($decodedResponse->meta->generatedAt), 'lightyellow', '');
504 503
                 Console::log();
505
-                foreach ($decodedResponse->data as $report){
504
+                foreach ($decodedResponse->data as $report) {
506 505
                     $score = empty($report->abuseConfidenceScore) ? 0 : $report->abuseConfidenceScore;
507 506
                     $defaultColor = self::getScoreColor($score);
508 507
 
@@ -537,12 +536,12 @@  discard block
 block discarded – undo
537 536
      */
538 537
     protected static function checkBlock(array $arguments): void
539 538
     {
540
-        $network  = self::getArgumentValue($arguments,'K', 'check-block');
539
+        $network = self::getArgumentValue($arguments, 'K', 'check-block');
541 540
 
542
-        self::printTitle(Console::text('  ► Check network: ', 'darkgray') . Console::text(escapeshellcmd($network), 'white') . Console::text('', 'darkgray'));
541
+        self::printTitle(Console::text('  ► Check network: ', 'darkgray').Console::text(escapeshellcmd($network), 'white').Console::text('', 'darkgray'));
543 542
 
544 543
         $maxAge   = self::getNumericParameter($arguments, 'd', 'days', 30);
545
-        $limit    = self::getNumericParameter($arguments,'l', 'limit', 0); // 0 mean no limit
544
+        $limit    = self::getNumericParameter($arguments, 'l', 'limit', 0); // 0 mean no limit
546 545
 
547 546
         self::printTempMessage();
548 547
 
@@ -553,19 +552,19 @@  discard block
 block discarded – undo
553 552
         self::clearTempMessage();
554 553
 
555 554
         // check for errors / empty response
556
-        if (self::hasErrors($check)){
555
+        if (self::hasErrors($check)) {
557 556
             self::printFooter($time);
558 557
             Program::exit(1);
559 558
         }
560 559
 
561
-        switch (self::$outputFormat){
560
+        switch (self::$outputFormat) {
562 561
             case self::OUTPUT_JSON:
563 562
                 echo json_encode($check, JSON_PRETTY_PRINT);
564 563
                 break;
565 564
        
566 565
             case self::OUTPUT_DEFAULT:  
567 566
                 self::printCheckBlockDetail($check);
568
-                self::printCheckBlockReportedIP($check,$maxAge,$limit);
567
+                self::printCheckBlockReportedIP($check, $maxAge, $limit);
569 568
                 Console::log();
570 569
                 self::printFooter($time);
571 570
                 break;
@@ -574,8 +573,8 @@  discard block
 block discarded – undo
574 573
                 $nbReports = isset($check->data->reportedAddress) ? count($check->data->reportedAddress) : 0;
575 574
                 if ($nbReports > 0) {
576 575
                     $numberDiplayedReports = 0;
577
-                    foreach ($check->data->reportedAddress as $report){
578
-                        echo ($report->ipAddress) . ' ' . $report->abuseConfidenceScore . PHP_EOL;
576
+                    foreach ($check->data->reportedAddress as $report) {
577
+                        echo ($report->ipAddress).' '.$report->abuseConfidenceScore.PHP_EOL;
579 578
 
580 579
                         // counter
581 580
                         $numberDiplayedReports++;
@@ -599,14 +598,14 @@  discard block
 block discarded – undo
599 598
      */
600 599
     protected static function checkIP(array $arguments): void
601 600
     {
602
-        $ip = self::getArgumentValue($arguments,'C', 'check');
601
+        $ip = self::getArgumentValue($arguments, 'C', 'check');
603 602
         
604
-        self::printTitle(Console::text('  ► Check IP: ', 'darkgray') . Console::text(escapeshellcmd($ip), 'white') . Console::text('', 'darkgray'));
603
+        self::printTitle(Console::text('  ► Check IP: ', 'darkgray').Console::text(escapeshellcmd($ip), 'white').Console::text('', 'darkgray'));
605 604
         
606
-        $verbose            = self::inArguments($arguments,'v', 'verbose');
605
+        $verbose            = self::inArguments($arguments, 'v', 'verbose');
607 606
         $maxAge             = self::getNumericParameter($arguments, 'd', 'days', 30);
608
-        $maxReportsNumber   = self::getNumericParameter($arguments,'l', 'limit', 10);
609
-        $ip                 = self::getArgumentValue($arguments,'C', 'check');
607
+        $maxReportsNumber   = self::getNumericParameter($arguments, 'l', 'limit', 10);
608
+        $ip                 = self::getArgumentValue($arguments, 'C', 'check');
610 609
 
611 610
         self::printTempMessage();
612 611
         $timeStart = microtime(true);                                           
@@ -616,7 +615,7 @@  discard block
 block discarded – undo
616 615
         self::clearTempMessage();
617 616
 
618 617
         // check for errors / empty response
619
-        if (self::hasErrors($check)){
618
+        if (self::hasErrors($check)) {
620 619
             self::printFooter($time);
621 620
             Program::exit(1);
622 621
         }
@@ -624,7 +623,7 @@  discard block
 block discarded – undo
624 623
         // score and data color (depending of abuseConfidenceScore)
625 624
         $score = empty($check->data->abuseConfidenceScore) ? 0 : $check->data->abuseConfidenceScore;
626 625
 
627
-        switch (self::$outputFormat){
626
+        switch (self::$outputFormat) {
628 627
             case self::OUTPUT_JSON:
629 628
                 echo json_encode($check, JSON_PRETTY_PRINT);
630 629
                 break;
@@ -634,7 +633,7 @@  discard block
 block discarded – undo
634 633
                 self::printCheckScore($check);
635 634
                 self::printCheckDetail($check, $defaultColor);
636 635
                 self::printCheckReports($check, $maxAge, $defaultColor);
637
-                if ($verbose){
636
+                if ($verbose) {
638 637
                     self::printCheckLastReports($check, $maxReportsNumber);
639 638
                 }
640 639
                 Console::log();
@@ -642,7 +641,7 @@  discard block
 block discarded – undo
642 641
                 break;
643 642
 
644 643
             case self::OUTPUT_PLAINTEXT:
645
-                echo ($check->data->abuseConfidenceScore ?? 0) . PHP_EOL;
644
+                echo ($check->data->abuseConfidenceScore ?? 0).PHP_EOL;
646 645
                 break;
647 646
 
648 647
         }
Please login to merge, or discard this patch.
src/AbstractClient.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     /**
38 38
      * @var string      
39 39
      */
40
-    const LONG_ARGUMENTS = ['output:', 'save-key:', 'config', 'list', 'blacklist', 'check:', 'check-block:', 'days:', 'report:', 'categories:', 'message:', 'limit:', 'clear:',' bulk-report:', 'help', 'verbose', 'score:', 'version'];
40
+    const LONG_ARGUMENTS = ['output:', 'save-key:', 'config', 'list', 'blacklist', 'check:', 'check-block:', 'days:', 'report:', 'categories:', 'message:', 'limit:', 'clear:', ' bulk-report:', 'help', 'verbose', 'score:', 'version'];
41 41
     
42 42
     /**
43 43
      * @var string
@@ -58,23 +58,23 @@  discard block
 block discarded – undo
58 58
      * @var array
59 59
      */
60 60
     protected static $basicCommands = [
61
-        ['h',           'help',         'printHelp'],
62
-        ['version',     'version',      'printVersion'],    // no short arg
63
-        ['S',           'save-key',     'registerApiKey'],  
61
+        ['h', 'help', 'printHelp'],
62
+        ['version', 'version', 'printVersion'], // no short arg
63
+        ['S', 'save-key', 'registerApiKey'],  
64 64
     ];
65 65
     
66 66
     /**
67 67
      * @var array
68 68
      */
69 69
     protected static $mainCommands = [
70
-        ['G',           'config',       'printConfig'],
71
-        ['L',           'list',         'printCategories'],
72
-        ['C',           'check',        'checkIP'],
73
-        ['K',           'check-block',  'checkBlock'],
74
-        ['R',           'report',       'reportIP'],
75
-        ['V',           'bulk-report',  'bulkReport'],
76
-        ['B',           'blacklist',    'getBlacklist'],
77
-        ['E',           'clear',        'clearIP'],
70
+        ['G', 'config', 'printConfig'],
71
+        ['L', 'list', 'printCategories'],
72
+        ['C', 'check', 'checkIP'],
73
+        ['K', 'check-block', 'checkBlock'],
74
+        ['R', 'report', 'reportIP'],
75
+        ['V', 'bulk-report', 'bulkReport'],
76
+        ['B', 'blacklist', 'getBlacklist'],
77
+        ['E', 'clear', 'clearIP'],
78 78
     ];
79 79
 
80 80
     /**
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
      */
90 90
     protected static function parseCommand(array $arguments, string $keyPath): bool
91 91
     {
92
-        foreach(self::$basicCommands as $cmd){
93
-            if (self::inArguments($arguments, $cmd[0], $cmd[1])){
94
-                call_user_func(__NAMESPACE__.'\AbuseIPDBClient::'.$cmd[2], $cmd[2]=== 'registerApiKey' ? $arguments : null);
92
+        foreach (self::$basicCommands as $cmd) {
93
+            if (self::inArguments($arguments, $cmd[0], $cmd[1])) {
94
+                call_user_func(__NAMESPACE__.'\AbuseIPDBClient::'.$cmd[2], $cmd[2] === 'registerApiKey' ? $arguments : null);
95 95
                 return true;
96 96
             }
97 97
         }
98
-        foreach(self::$mainCommands as $cmd){
99
-            if (self::inArguments($arguments, $cmd[0], $cmd[1])){
98
+        foreach (self::$mainCommands as $cmd) {
99
+            if (self::inArguments($arguments, $cmd[0], $cmd[1])) {
100 100
                 self::createHandler($keyPath);
101 101
                 self::setOutputFormat($arguments);                    
102 102
                 call_user_func(__NAMESPACE__.'\AbuseIPDBClient::'.$cmd[2], $arguments);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         $given = self::getArgumentValue($arguments, 'o', 'output') ?? 'default';
122 122
         $output = empty($given) ? 'default' : $given; 
123 123
         self::validate(in_array($output, ['default', 'json', 'plaintext']), 'Invalid output argument given.');
124
-        self::$outputFormat = $output ;
124
+        self::$outputFormat = $output;
125 125
     }
126 126
 
127 127
     /**
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
     public static function fromConfigFile(string $configPath): QuietApiHandler
176 176
     {
177 177
         // check file exists
178
-        if (!file_exists($configPath) || !is_file($configPath)){
178
+        if (!file_exists($configPath) || !is_file($configPath)) {
179 179
             throw new \InvalidArgumentException('The file ['.$configPath.'] does not exist.');
180 180
         }
181 181
 
182 182
         // check file is readable
183
-        if (!is_readable($configPath)){
183
+        if (!is_readable($configPath)) {
184 184
             throw new InvalidPermissionException('The file ['.$configPath.'] is not readable.');
185 185
         }
186 186
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         
190 190
         // Look for other optional config files in the same directory 
191 191
         $selfIpsConfigPath = pathinfo($configPath, PATHINFO_DIRNAME).DIRECTORY_SEPARATOR.'self_ips.json';
192
-        if (file_exists($selfIpsConfigPath)){
192
+        if (file_exists($selfIpsConfigPath)) {
193 193
             $selfIps = self::loadJsonFile($selfIpsConfigPath)->self_ips;
194 194
         }
195 195
 
Please login to merge, or discard this patch.
src/BulkReportTrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
     protected static function printBulkReportDetail(string $fileName): void
41 41
     {
42 42
         Console::log(
43
-            Console::text('   Bulk report for file: [', 'white') .
44
-            Console::text($fileName, 'lightyellow') .
43
+            Console::text('   Bulk report for file: [', 'white').
44
+            Console::text($fileName, 'lightyellow').
45 45
             Console::text('] done!', 'white')
46 46
         );
47 47
     }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $nbSavedReports = isset($response->data->savedReports) ? $response->data->savedReports : 0;
62 62
         $savedColor = $nbSavedReports > 0 ? 'green' : 'red';
63 63
         $savedIcon  = $nbSavedReports > 0 ? '✓' : '✗';
64
-        Console::log(Console::text('   ' . $savedIcon, $savedColor) . self::printResult(' Saved reports:    ', $nbSavedReports, $savedColor, '', false));
64
+        Console::log(Console::text('   '.$savedIcon, $savedColor).self::printResult(' Saved reports:    ', $nbSavedReports, $savedColor, '', false));
65 65
     }
66 66
 
67 67
     /**
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
         $errorColor = $nbErrorReports > 0 ? 'red' : 'green';
81 81
         $errorIcon  = $nbErrorReports > 0 ? '✗' : '✓';
82 82
 
83
-        Console::log(Console::text('   ' . $errorIcon, $errorColor) . self::printResult(' Invalid reports:  ', $nbErrorReports, $errorColor, '', false));
83
+        Console::log(Console::text('   '.$errorIcon, $errorColor).self::printResult(' Invalid reports:  ', $nbErrorReports, $errorColor, '', false));
84 84
 
85
-        if ($nbErrorReports > 0){
85
+        if ($nbErrorReports > 0) {
86 86
             $numberDiplayedReports = 0;
87 87
             $defaultColor = 'lightyellow'; // reset color for last reports
88 88
 
89
-            foreach ($response->data->invalidReports as $report){
89
+            foreach ($response->data->invalidReports as $report) {
90 90
                 $input = $report->input ? escapeshellcmd($report->input) : ''; // in case on blank line, IP is null
91
-                Console::log(Console::text('      →', 'red') . self::printResult(' Input:         ', $input, $defaultColor, '', false));
91
+                Console::log(Console::text('      →', 'red').self::printResult(' Input:         ', $input, $defaultColor, '', false));
92 92
                 self::printResult('        Error:         ', $report->error, $defaultColor);
93 93
                 self::printResult('        Line number:   ', $report->rowNumber, $defaultColor);
94 94
                 
Please login to merge, or discard this patch.
src/ShellUtils.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
     /**
38 38
      * @var string      
39 39
      */
40
-    const OUTPUT_JSON       = 'json';
40
+    const OUTPUT_JSON = 'json';
41 41
 
42 42
     /**
43 43
      * @var string      
44 44
      */
45
-    const OUTPUT_DEFAULT    = 'default';
45
+    const OUTPUT_DEFAULT = 'default';
46 46
 
47 47
     /**
48 48
      * @var string      
49 49
      */
50
-    const OUTPUT_PLAINTEXT  = 'plaintext';
50
+    const OUTPUT_PLAINTEXT = 'plaintext';
51 51
     
52 52
     /**
53 53
      * @var string      $outputFormat
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     protected static function printTempMessage(): void
93 93
     {
94 94
         if (self::isDefaultOuput()) {
95
-            Console::reLog(Console::text('   ? ', 'green') . Console::text('waiting for api response', 'white') . Console::text(' ... ', 'green'));
95
+            Console::reLog(Console::text('   ? ', 'green').Console::text('waiting for api response', 'white').Console::text(' ... ', 'green'));
96 96
         }
97 97
     }
98 98
 
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
         self::printLogo();
147 147
 
148 148
         Console::log();
149
-        Console::log(Console::text('  Kristuff/AbuseIPDB Client version: ', 'darkgray') . Console::text(AbuseIPDBClient::VERSION, 'lightgray'));
150
-        Console::log(Console::text('  Kristuff/AbuseIPDB Core version:   ', 'darkgray') . Console::text(ApiHandler::VERSION, 'lightgray')); 
149
+        Console::log(Console::text('  Kristuff/AbuseIPDB Client version: ', 'darkgray').Console::text(AbuseIPDBClient::VERSION, 'lightgray'));
150
+        Console::log(Console::text('  Kristuff/AbuseIPDB Core version:   ', 'darkgray').Console::text(ApiHandler::VERSION, 'lightgray')); 
151 151
         Console::log(Console::text('  --------------------------------------------------', 'darkgray'));    
152 152
         Console::log(Console::text('  Released under the MIT licence', 'darkgray'));
153
-        Console::log(Console::text('  Made with ', 'darkgray') . Console::text('♥', 'red') . Console::text(' in France', 'darkgray'));
153
+        Console::log(Console::text('  Made with ', 'darkgray').Console::text('♥', 'red').Console::text(' in France', 'darkgray'));
154 154
         Console::log(
155 155
             Console::text('  © 2020-2021 Kristuff (', 'darkgray').
156 156
             Console::text('https://github.com/kristuff', 'darkgray', 'underlined').
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
     {
173 173
         if (self::isDefaultOuput()) {
174 174
             Console::log();    
175
-            Console::log( Console::text(' Kristuff/AbuseIPDB-client ', 'darkgray') . Console::text(' ' . AbuseIPDBClient::VERSION . ' ', 'white', 'blue')); 
176
-            Console::log(Console::text(' Made with ', 'darkgray') . Console::text('♥', 'red') . Console::text(' in France', 'darkgray')); 
175
+            Console::log(Console::text(' Kristuff/AbuseIPDB-client ', 'darkgray').Console::text(' '.AbuseIPDBClient::VERSION.' ', 'white', 'blue')); 
176
+            Console::log(Console::text(' Made with ', 'darkgray').Console::text('♥', 'red').Console::text(' in France', 'darkgray')); 
177 177
             Console::log(Console::text(' © 2020-2021 Kristuff (', 'darkgray').
178 178
                 Console::text('https://github.com/kristuff', 'darkgray', 'underlined').
179 179
                 Console::text(')', 'darkgray')
@@ -193,19 +193,19 @@  discard block
 block discarded – undo
193 193
     protected static function printFooter($requestTime = ''): void
194 194
     {
195 195
         if (self::isDefaultOuput()) {
196
-            if (!empty($requestTime)){
196
+            if (!empty($requestTime)) {
197 197
                 $date_utc = new \DateTime("now", new \DateTimeZone("UTC"));
198 198
                 Console::log(
199
-                    Console::text('  Request time: ', 'darkgray') . Console::text($requestTime . 's', 'lightgray'). 
200
-                    Console::text(' | UTC time: ', 'darkgray') . Console::text($date_utc->format('Y-m-d H:i:s'), 'lightgray')
199
+                    Console::text('  Request time: ', 'darkgray').Console::text($requestTime.'s', 'lightgray'). 
200
+                    Console::text(' | UTC time: ', 'darkgray').Console::text($date_utc->format('Y-m-d H:i:s'), 'lightgray')
201 201
                 );
202 202
             }
203 203
             Console::log(Console::text('  ------------------------------------------------------------------------------------------------------', 'darkgray')); 
204 204
             Console::log(
205
-                Console::text('  Kristuff\AbuseIPDB ', 'darkgray') . 
206
-                Console::text(AbuseIPDBClient::VERSION, 'lightgray') . 
207
-                Console::text(' | Made with ', 'darkgray') . 
208
-                Console::text('♥', 'red') .
205
+                Console::text('  Kristuff\AbuseIPDB ', 'darkgray'). 
206
+                Console::text(AbuseIPDBClient::VERSION, 'lightgray'). 
207
+                Console::text(' | Made with ', 'darkgray'). 
208
+                Console::text('♥', 'red').
209 209
                 Console::text(' in France | © 2020-2021 Kristuff (https://github.com/kristuff)', 'darkgray')
210 210
             ); 
211 211
             Console::log(); 
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
     protected static function printResult($text, $value, string $foregroundColor = 'lightred', string $backgroundColor = '', bool $print = true): string
224 224
     {
225 225
         // do not print null/blank values
226
-        if (isset($value)){
227
-            $line = Console::text($text, 'white') . Console::text($value, $foregroundColor, $backgroundColor); 
228
-            if ($print && self::isDefaultOuput()){
226
+        if (isset($value)) {
227
+            $line = Console::text($text, 'white').Console::text($value, $foregroundColor, $backgroundColor); 
228
+            if ($print && self::isDefaultOuput()) {
229 229
                 Console::log($line);
230 230
             }
231 231
             return $line;
@@ -249,16 +249,16 @@  discard block
 block discarded – undo
249 249
         $scoreforegroundColor = 'white';
250 250
         $scoreBackgroundColor = 'green';
251 251
 
252
-        if (intval($score) > 0 ){
252
+        if (intval($score) > 0) {
253 253
             $scoreforegroundColor = 'black';
254 254
             $scoreBackgroundColor = 'yellow';
255 255
         } 
256
-        if (intval($score) > 50 ){
256
+        if (intval($score) > 50) {
257 257
             $scoreforegroundColor = 'white';
258 258
             $scoreBackgroundColor = 'red';
259 259
         } 
260 260
   
261
-        $badge = str_pad(strval($score), 3, ' ',STR_PAD_LEFT); 
261
+        $badge = str_pad(strval($score), 3, ' ', STR_PAD_LEFT); 
262 262
         return Console::text($padding.$badge.$padding, $scoreforegroundColor, $scoreBackgroundColor);
263 263
     }
264 264
 }
265 265
\ No newline at end of file
Please login to merge, or discard this patch.