Passed
Push — master ( 10f881...c94328 )
by Kris
02:27
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   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     protected static function printCheckScore(object $response): void
40 40
     {
41 41
         $score = empty($response->data->abuseConfidenceScore) ? 0 : $response->data->abuseConfidenceScore;
42
-        $line = Console::text(Console::pad('   Confidence score:', 23), 'white') . self::getScoreBadge($score);
42
+        $line = Console::text(Console::pad('   Confidence score:', 23), 'white').self::getScoreBadge($score);
43 43
         Console::log($line);
44 44
     }
45 45
 
@@ -58,26 +58,26 @@  discard block
 block discarded – undo
58 58
         //  self::printResult('   isPublic', $response->data->isPublic, $defaultColor);
59 59
         //  self::printResult('   ipVersion', $response->data->ipVersion, $defaultColor);
60 60
  
61
-        $line = self::printResult(Console::pad('   Whitelisted:', 23), $response->data->isWhitelisted ? 'true': 'false', $color, '', false);
61
+        $line = self::printResult(Console::pad('   Whitelisted:', 23), $response->data->isWhitelisted ? 'true' : 'false', $color, '', false);
62 62
         $line .= $response->data->isWhitelisted ? Console::text(' ★', 'green') : ''; 
63 63
         Console::log($line);
64 64
        
65 65
         self::printResult(Console::pad('   Country code:', 23), $response->data->countryCode, $color);
66 66
         
67
-        if (!empty($response->data->countryName)){
67
+        if (!empty($response->data->countryName)) {
68 68
             self::printResult(Console::pad('   Country name:', 23), $response->data->countryName, $color);
69 69
         }
70 70
 
71 71
         self::printResult(Console::pad('   ISP:', 23), $response->data->isp, $color);
72 72
 
73
-        if ($response->data->usageType){
73
+        if ($response->data->usageType) {
74 74
             $line = self::printResult(Console::pad('   Usage type:', 23), $response->data->usageType, $color, '', false);
75 75
             $line .= $response->data->usageType === 'Reserved' ? Console::text(' ◆', 'green') : '';
76 76
             Console::log($line);
77 77
         }
78 78
 
79 79
         $hostames = implode(', ', array_filter($response->data->hostnames)) ?? null;
80
-        if (!empty($hostames)){
80
+        if (!empty($hostames)) {
81 81
             self::printResult(Console::pad('   Hostname(s):', 23), $hostames, $color);
82 82
         }
83 83
 
@@ -99,28 +99,28 @@  discard block
 block discarded – undo
99 99
     {
100 100
         $nbReport = $response->data->totalReports && is_numeric($response->data->totalReports) ? intval($response->data->totalReports) : 0;
101 101
         
102
-        if ($nbReport > 0 ){
102
+        if ($nbReport > 0) {
103 103
             $line  = self::printResult(Console::pad('   Total reports:', 23), $nbReport, $color, '', false);
104 104
             $line .= self::printResult(' from ', $response->data->numDistinctUsers, $color, '', false);
105
-            $line .= Console::text($nbReport > 0 ? ' distinct users': ' user', 'white');
105
+            $line .= Console::text($nbReport > 0 ? ' distinct users' : ' user', 'white');
106 106
             Console::log($line);
107 107
 
108 108
         } else {
109 109
             // no reports
110
-            $period = $maxAge > 1 ? 'in last '. $maxAge . ' days': ' today';
111
-            if (empty($response->data->lastReportedAt)){
112
-                Console::log( Console::text('   ✓', 'green') . Console::text(' Not reported ' . $period));
110
+            $period = $maxAge > 1 ? 'in last '.$maxAge.' days' : ' today';
111
+            if (empty($response->data->lastReportedAt)) {
112
+                Console::log(Console::text('   ✓', 'green').Console::text(' Not reported '.$period));
113 113
             
114 114
             } else {
115 115
                 // in some case, we have no reports but lastReportedAt in not empty (when deleting reports for example)
116 116
                 // maybe a bug or cache in api 
117 117
                 // In this case Set total 0 and let print lastReportedAt
118
-                $line  = self::printResult(Console::pad('   Total reports:', 23), $nbReport, $color, '', false);
118
+                $line = self::printResult(Console::pad('   Total reports:', 23), $nbReport, $color, '', false);
119 119
                 Console::log($line);
120 120
             }
121 121
         }
122 122
         
123
-        if (!empty($response->data->lastReportedAt)){
123
+        if (!empty($response->data->lastReportedAt)) {
124 124
             self::printResult(Console::pad('   Last reported at:', 23), self::getDate($response->data->lastReportedAt), $color);
125 125
         }
126 126
     }
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
     {
141 141
         $nbLastReports = isset($response->data->reports) ? count($response->data->reports) : 0;
142 142
             
143
-        if ($nbLastReports > 0){
143
+        if ($nbLastReports > 0) {
144 144
             Console::log('   Last reports:', 'white');
145 145
             $numberDiplayedReports = 0;
146 146
             $defaultColor = 'lightyellow'; // reset color for last reports
147 147
         
148
-            foreach ($response->data->reports as $report){
148
+            foreach ($response->data->reports as $report) {
149 149
                 self::printLastReport($report);
150 150
                 $numberDiplayedReports++;
151 151
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                     $line .= Console::text($numberDiplayedReports, $defaultColor);
155 155
                     $line .= Console::text('/', 'white');
156 156
                     $line .= Console::text($nbLastReports, $defaultColor);
157
-                    $line .= Console::text($numberDiplayedReports > 1 ? ' reports displayed)': ' report displayed)', 'white');
157
+                    $line .= Console::text($numberDiplayedReports > 1 ? ' reports displayed)' : ' report displayed)', 'white');
158 158
                     Console::log($line);
159 159
                     break;
160 160
                 }
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
         $line  = Console::text('    →', $defaultColor);
180 180
         $line .= self::printResult(' reported at: ', self::getDate($report->reportedAt), $defaultColor, '', false);
181 181
   //    $line .= self::printResult(' by user: ', $report->reporterId, $defaultColor, '', false);
182
-        if (isset($report->reporterCountryCode) && isset($report->reporterCountryName)){
182
+        if (isset($report->reporterCountryCode) && isset($report->reporterCountryName)) {
183 183
             $line .= Console::text(' from: ', 'white');
184 184
             $line .= self::printResult('', $report->reporterCountryCode, $defaultColor, '', false);
185 185
             $line .= Console::text(' - ', 'white');
186 186
             $line .= self::printResult('', $report->reporterCountryName, $defaultColor, '', false);
187 187
         }
188
-        $line .= Console::text(' with categor' .  (count($categories) > 1 ? "ies: " : "y: "), 'white');
188
+        $line .= Console::text(' with categor'.(count($categories) > 1 ? "ies: " : "y: "), 'white');
189 189
         foreach ($categories as $key => $cat) {
190
-            $line .= Console::text($key==0 ? '' : ',' , 'white') . Console::text($cat, $defaultColor);
190
+            $line .= Console::text($key == 0 ? '' : ',', 'white').Console::text($cat, $defaultColor);
191 191
         }
192 192
         Console::log($line);
193 193
     }  
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     private static function getLastReportsCategories(object $report): array
205 205
     {
206 206
         $categories = [];
207
-        foreach (array_filter($report->categories) as $catId){
207
+        foreach (array_filter($report->categories) as $catId) {
208 208
             $cat = ApiHandler::getCategoryNameById(strval($catId));
209 209
             if ($cat !== false) {
210 210
                 $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/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/AbuseIPDBClient.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -69,51 +69,51 @@
 block discarded – undo
69 69
         Console::log();
70 70
         Console::log(' ' . Console::text('SYNOPSIS:', 'white', 'underline')); 
71 71
         Console::log(' ' . Console::text('    abuseipdb -C ') . 
72
-                           Console::text('IP', 'yellow') . 
73
-                           Console::text(' [-d ') . 
74
-                           Console::text('DAYS', 'yellow') . 
75
-                           Console::text('] [-v] [-l ') . 
76
-                           Console::text('LIMIT', 'yellow') . 
77
-                           Console::text('] [-o ') . 
78
-                           Console::text('FORMAT', 'yellow') . 
79
-                           Console::text(']')); 
72
+                            Console::text('IP', 'yellow') . 
73
+                            Console::text(' [-d ') . 
74
+                            Console::text('DAYS', 'yellow') . 
75
+                            Console::text('] [-v] [-l ') . 
76
+                            Console::text('LIMIT', 'yellow') . 
77
+                            Console::text('] [-o ') . 
78
+                            Console::text('FORMAT', 'yellow') . 
79
+                            Console::text(']')); 
80 80
 
81 81
         Console::log(' ' . Console::text('    abuseipdb -K ') . 
82
-                           Console::text('NETWORK', 'yellow') . 
83
-                           Console::text(' [-d ') . 
84
-                           Console::text('DAYS', 'yellow') . 
85
-                           Console::text('] [-o ') . 
86
-                           Console::text('FORMAT', 'yellow') . 
87
-                           Console::text(']')); 
82
+                            Console::text('NETWORK', 'yellow') . 
83
+                            Console::text(' [-d ') . 
84
+                            Console::text('DAYS', 'yellow') . 
85
+                            Console::text('] [-o ') . 
86
+                            Console::text('FORMAT', 'yellow') . 
87
+                            Console::text(']')); 
88 88
 
89 89
         Console::log(' ' . Console::text('    abuseipdb -R ') .
90
-                           Console::text('IP', 'yellow') . ' -c ' .
91
-                           Console::text('CATEGORIES', 'yellow') . ' -m ' .
92
-                           Console::text('MESSAGE', 'yellow') .
93
-                           Console::text(' [-o ') . 
94
-                           Console::text('FORMAT', 'yellow') . 
95
-                           Console::text(']')); 
90
+                            Console::text('IP', 'yellow') . ' -c ' .
91
+                            Console::text('CATEGORIES', 'yellow') . ' -m ' .
92
+                            Console::text('MESSAGE', 'yellow') .
93
+                            Console::text(' [-o ') . 
94
+                            Console::text('FORMAT', 'yellow') . 
95
+                            Console::text(']')); 
96 96
 
97 97
         Console::log(' ' . Console::text('    abuseipdb -V ') .
98
-                           Console::text('FILE', 'yellow') .
99
-                           Console::text(' [-o ') . 
100
-                           Console::text('FORMAT', 'yellow') . 
101
-                           Console::text(']')); 
98
+                            Console::text('FILE', 'yellow') .
99
+                            Console::text(' [-o ') . 
100
+                            Console::text('FORMAT', 'yellow') . 
101
+                            Console::text(']')); 
102 102
 
103 103
         Console::log(' ' . Console::text('    abuseipdb -E ') .
104
-                           Console::text('IP', 'yellow').
105
-                           Console::text(' [-o ') . 
106
-                           Console::text('FORMAT', 'yellow') . 
107
-                           Console::text(']')); 
104
+                            Console::text('IP', 'yellow').
105
+                            Console::text(' [-o ') . 
106
+                            Console::text('FORMAT', 'yellow') . 
107
+                            Console::text(']')); 
108 108
                            
109 109
         Console::log(' ' . Console::text('    abuseipdb -B ') . 
110
-                           Console::text('[-l ') . 
111
-                           Console::text('LIMIT', 'yellow') . 
112
-                           Console::text('] [-s ') . 
113
-                           Console::text('SCORE', 'yellow') . 
114
-                           Console::text('] [-o ') . 
115
-                           Console::text('FORMAT', 'yellow') . 
116
-                           Console::text(']')); 
110
+                            Console::text('[-l ') . 
111
+                            Console::text('LIMIT', 'yellow') . 
112
+                            Console::text('] [-s ') . 
113
+                            Console::text('SCORE', 'yellow') . 
114
+                            Console::text('] [-o ') . 
115
+                            Console::text('FORMAT', 'yellow') . 
116
+                            Console::text(']')); 
117 117
 
118 118
         Console::log(' ' . Console::text('    abuseipdb -L | -G | -h | --version'));
119 119
                            
Please login to merge, or discard this patch.
Spacing   +110 added lines, -111 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     public static function start(array $arguments, string $confPath): void
47 47
     {
48 48
         // required at least one valid argument
49
-        self::validate( !empty($arguments), 'No valid arguments given. Run abuseipdb --help to get help.');
49
+        self::validate(!empty($arguments), 'No valid arguments given. Run abuseipdb --help to get help.');
50 50
         self::$configPath = $confPath; 
51 51
         if (!self::parseCommand($arguments, $confPath)) {
52 52
             self::error('Invalid arguments. Run abuseipdb --help to get help.');
@@ -67,58 +67,58 @@  discard block
 block discarded – undo
67 67
     protected static function printHelp(): void
68 68
     {
69 69
         Console::log();
70
-        Console::log(' ' . Console::text('SYNOPSIS:', 'white', 'underline')); 
71
-        Console::log(' ' . Console::text('    abuseipdb -C ') . 
72
-                           Console::text('IP', 'yellow') . 
73
-                           Console::text(' [-d ') . 
74
-                           Console::text('DAYS', 'yellow') . 
75
-                           Console::text('] [-v] [-l ') . 
76
-                           Console::text('LIMIT', 'yellow') . 
77
-                           Console::text('] [-o ') . 
78
-                           Console::text('FORMAT', 'yellow') . 
70
+        Console::log(' '.Console::text('SYNOPSIS:', 'white', 'underline')); 
71
+        Console::log(' '.Console::text('    abuseipdb -C '). 
72
+                           Console::text('IP', 'yellow'). 
73
+                           Console::text(' [-d '). 
74
+                           Console::text('DAYS', 'yellow'). 
75
+                           Console::text('] [-v] [-l '). 
76
+                           Console::text('LIMIT', 'yellow'). 
77
+                           Console::text('] [-o '). 
78
+                           Console::text('FORMAT', 'yellow'). 
79 79
                            Console::text(']')); 
80 80
 
81
-        Console::log(' ' . Console::text('    abuseipdb -K ') . 
82
-                           Console::text('NETWORK', 'yellow') . 
83
-                           Console::text(' [-d ') . 
84
-                           Console::text('DAYS', 'yellow') . 
85
-                           Console::text('] [-o ') . 
86
-                           Console::text('FORMAT', 'yellow') . 
81
+        Console::log(' '.Console::text('    abuseipdb -K '). 
82
+                           Console::text('NETWORK', 'yellow'). 
83
+                           Console::text(' [-d '). 
84
+                           Console::text('DAYS', 'yellow'). 
85
+                           Console::text('] [-o '). 
86
+                           Console::text('FORMAT', 'yellow'). 
87 87
                            Console::text(']')); 
88 88
 
89
-        Console::log(' ' . Console::text('    abuseipdb -R ') .
90
-                           Console::text('IP', 'yellow') . ' -c ' .
91
-                           Console::text('CATEGORIES', 'yellow') . ' -m ' .
92
-                           Console::text('MESSAGE', 'yellow') .
93
-                           Console::text(' [-o ') . 
94
-                           Console::text('FORMAT', 'yellow') . 
89
+        Console::log(' '.Console::text('    abuseipdb -R ').
90
+                           Console::text('IP', 'yellow').' -c '.
91
+                           Console::text('CATEGORIES', 'yellow').' -m '.
92
+                           Console::text('MESSAGE', 'yellow').
93
+                           Console::text(' [-o '). 
94
+                           Console::text('FORMAT', 'yellow'). 
95 95
                            Console::text(']')); 
96 96
 
97
-        Console::log(' ' . Console::text('    abuseipdb -V ') .
98
-                           Console::text('FILE', 'yellow') .
99
-                           Console::text(' [-o ') . 
100
-                           Console::text('FORMAT', 'yellow') . 
97
+        Console::log(' '.Console::text('    abuseipdb -V ').
98
+                           Console::text('FILE', 'yellow').
99
+                           Console::text(' [-o '). 
100
+                           Console::text('FORMAT', 'yellow'). 
101 101
                            Console::text(']')); 
102 102
 
103
-        Console::log(' ' . Console::text('    abuseipdb -E ') .
103
+        Console::log(' '.Console::text('    abuseipdb -E ').
104 104
                            Console::text('IP', 'yellow').
105
-                           Console::text(' [-o ') . 
106
-                           Console::text('FORMAT', 'yellow') . 
105
+                           Console::text(' [-o '). 
106
+                           Console::text('FORMAT', 'yellow'). 
107 107
                            Console::text(']')); 
108 108
                            
109
-        Console::log(' ' . Console::text('    abuseipdb -B ') . 
110
-                           Console::text('[-l ') . 
111
-                           Console::text('LIMIT', 'yellow') . 
112
-                           Console::text('] [-s ') . 
113
-                           Console::text('SCORE', 'yellow') . 
114
-                           Console::text('] [-o ') . 
115
-                           Console::text('FORMAT', 'yellow') . 
109
+        Console::log(' '.Console::text('    abuseipdb -B '). 
110
+                           Console::text('[-l '). 
111
+                           Console::text('LIMIT', 'yellow'). 
112
+                           Console::text('] [-s '). 
113
+                           Console::text('SCORE', 'yellow'). 
114
+                           Console::text('] [-o '). 
115
+                           Console::text('FORMAT', 'yellow'). 
116 116
                            Console::text(']')); 
117 117
 
118
-        Console::log(' ' . Console::text('    abuseipdb -L | -G | -h | --version'));
118
+        Console::log(' '.Console::text('    abuseipdb -L | -G | -h | --version'));
119 119
                            
120 120
         Console::log();    
121
-        Console::log(' ' . Console::text('OPTIONS:', 'white', 'underline')); 
121
+        Console::log(' '.Console::text('OPTIONS:', 'white', 'underline')); 
122 122
         Console::log();
123 123
         Console::log(Console::text('   -h, --help', 'white')); 
124 124
         Console::log('       Prints the current help.', 'lightgray');
@@ -129,61 +129,61 @@  discard block
 block discarded – undo
129 129
         Console::log(Console::text('   -L, --list', 'white')); 
130 130
         Console::log('       Prints the list report categories.', 'lightgray');
131 131
         Console::log();    
132
-        Console::log(Console::text('   -C, --check ', 'white') . Console::text('IP', 'yellow', 'underline')); 
132
+        Console::log(Console::text('   -C, --check ', 'white').Console::text('IP', 'yellow', 'underline')); 
133 133
         Console::log('       Performs a check request for the given IP address. A valid IPv4 or IPv6 address is required.', 'lightgray');
134 134
         Console::log();    
135
-        Console::log(Console::text('   -K, --check-block ', 'white') . Console::text('NETWORK', 'yellow', 'underline')); 
135
+        Console::log(Console::text('   -K, --check-block ', 'white').Console::text('NETWORK', 'yellow', 'underline')); 
136 136
         Console::log('       Performs a check-block request for the given network. A valid subnet (v4 or v6) denoted with ', 'lightgray');
137 137
         Console::log('       CIDR notation is required.', 'lightgray');
138 138
         Console::log();    
139
-        Console::log(Console::text('   -d, --days ', 'white') . Console::text('DAYS', 'yellow', 'underline')); 
139
+        Console::log(Console::text('   -d, --days ', 'white').Console::text('DAYS', 'yellow', 'underline')); 
140 140
         Console::log('       For a check or check-block request, defines the maxAgeDays. Min is 1, max is 365, default is 30.', 'lightgray');
141 141
         Console::log();    
142
-        Console::log(Console::text('   -R, --report ', 'white') . Console::text('IP', 'yellow', 'underline')); 
142
+        Console::log(Console::text('   -R, --report ', 'white').Console::text('IP', 'yellow', 'underline')); 
143 143
         Console::log('       Performs a report request for the given IP address. A valid IPv4 or IPv6 address is required.', 'lightgray');
144 144
         Console::log();    
145
-        Console::log(Console::text('   -V, --bulk-report ', 'white') . Console::text('FILE', 'yellow', 'underline')); 
145
+        Console::log(Console::text('   -V, --bulk-report ', 'white').Console::text('FILE', 'yellow', 'underline')); 
146 146
         Console::log('       Performs a bulk-report request sending a csv file. A valid file name or full path is required.', 'lightgray');
147 147
         Console::log();    
148 148
         Console::log(Console::text('   -E, --clear ', 'white')); 
149 149
         Console::log('       Remove own reports for the given IP address. A valid IPv4 or IPv6 address is required.', 'lightgray');
150 150
         Console::log();
151
-        Console::log(Console::text('   -c, --categories ', 'white') . Console::text('CATEGORIES', 'yellow', 'underline')); 
151
+        Console::log(Console::text('   -c, --categories ', 'white').Console::text('CATEGORIES', 'yellow', 'underline')); 
152 152
         Console::log('       For a report request, defines the report category(ies). Categories must be separate by a comma.', 'lightgray');
153 153
         Console::log('       Some categories cannot be used alone. A category can be represented by its shortname or by its', 'lightgray');
154
-        Console::log(Console::text('       id. Use ','lightgray')  . Console::text('abuseipdb -L', 'white') . Console::text(' to print the categories list.','lightgray'));
154
+        Console::log(Console::text('       id. Use ', 'lightgray').Console::text('abuseipdb -L', 'white').Console::text(' to print the categories list.', 'lightgray'));
155 155
         Console::log();    
156
-        Console::log(Console::text('   -m, --message ', 'white') . Console::text('MESSAGE', 'yellow', 'underline')); 
156
+        Console::log(Console::text('   -m, --message ', 'white').Console::text('MESSAGE', 'yellow', 'underline')); 
157 157
         Console::log('       For a report request, defines the message to send with report. Message is required for all', 'lightgray');
158 158
         Console::log('       report requests.', 'lightgray');
159 159
         Console::log();
160 160
         Console::log(Console::text('   -B, --blacklist ', 'white')); 
161 161
         Console::log('       Performs a blacklist request. Default limit is 1000. This limit can ne changed with the', 'lightgray');
162
-        Console::log('       ' . Console::text('--limit', 'white') . Console::text(' parameter. ', 'lightgray'));
162
+        Console::log('       '.Console::text('--limit', 'white').Console::text(' parameter. ', 'lightgray'));
163 163
         Console::log();    
164
-        Console::log(Console::text('   -l, --limit ', 'white') . Console::text('LIMIT', 'yellow', 'underline')); 
164
+        Console::log(Console::text('   -l, --limit ', 'white').Console::text('LIMIT', 'yellow', 'underline')); 
165 165
         Console::log('       For a blacklist request, defines the limit.', 'lightgray');
166 166
         Console::log('       For a check request with verbose flag, sets the max number of last reports displayed. Default is 10', 'lightgray');
167 167
         Console::log('       For a check-block request, sets the max number of IPs displayed. Default is 0 (no limit).', 'lightgray');
168 168
         Console::log();    
169
-        Console::log(Console::text('   -o, --output ', 'white') . Console::text('FORMAT', 'yellow', 'underline')); 
169
+        Console::log(Console::text('   -o, --output ', 'white').Console::text('FORMAT', 'yellow', 'underline')); 
170 170
         Console::log('       Defines the output format for API requests. Default is a colorized report, possible formats are', 'lightgray');
171
-        Console::log('       '. Console::text('json', 'yellow', 'underline') . ' or ' . Console::text('plaintext', 'yellow', 'underline') . '. Plaintext option prints partial response (blacklist: IPs list, ');
171
+        Console::log('       '.Console::text('json', 'yellow', 'underline').' or '.Console::text('plaintext', 'yellow', 'underline').'. Plaintext option prints partial response (blacklist: IPs list, ');
172 172
         Console::log('       check or report: confidence score only, check-block: reported IPs list with confidence score, ', 'lightgray');
173 173
         Console::log('       bulk-report: number of saved reports, clear: number of deleted reports).', 'lightgray');
174 174
         Console::log();    
175
-        Console::log(Console::text('   -s, --score ', 'white'). Console::text('SCORE', 'yellow', 'underline')); 
175
+        Console::log(Console::text('   -s, --score ', 'white').Console::text('SCORE', 'yellow', 'underline')); 
176 176
         Console::log('       For a blacklist request, sets the confidence score minimum. The confidence minimum ', 'lightgray');
177 177
         Console::log('       must be between 25 and 100. This parameter is subscriber feature (not honored otherwise, allways 100).', 'lightgray');
178 178
         Console::log();    
179
-        Console::log(Console::text('   -t, --timeout ', 'white'). Console::text('TIMEOUT', 'yellow', 'underline')); 
179
+        Console::log(Console::text('   -t, --timeout ', 'white').Console::text('TIMEOUT', 'yellow', 'underline')); 
180 180
         Console::log('       Define the timeout in API request and overwrite the value defined in conf.ini or local.ini.', 'lightgray');
181 181
         Console::log('       Timeout is expressed in milliseconds.', 'lightgray');
182 182
         Console::log();    
183 183
         Console::log(Console::text('   -v, --verbose ', 'white')); 
184 184
         Console::log('       For a check request, display additional fields like the x last reports. This increases ', 'lightgray');
185 185
         Console::log(Console::text('       request time and response size. Max number of last reports displayed can be changed with the ', 'lightgray'));
186
-        Console::log('       ' . Console::text('--limit', 'white') . Console::text(' parameter. ', 'lightgray'));
186
+        Console::log('       '.Console::text('--limit', 'white').Console::text(' parameter. ', 'lightgray'));
187 187
         Console::log();    
188 188
         Console::log(Console::text('   --version', 'white')); 
189 189
         Console::log('       Prints the current version.', 'lightgray');
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
 
206 206
         self::printTitle(Console::text('  ► Current configuration ', 'darkgray'));
207 207
         
208
-        Console::log(Console::text('  api_key:[', 'white') . Console::text($conf['apiKey'], 'green') . Console::text(']', 'white'));
209
-        Console::log(Console::text('  timeout:[', 'white') . Console::text($conf['timeout'], 'green') . Console::text(']', 'white'));
208
+        Console::log(Console::text('  api_key:[', 'white').Console::text($conf['apiKey'], 'green').Console::text(']', 'white'));
209
+        Console::log(Console::text('  timeout:[', 'white').Console::text($conf['timeout'], 'green').Console::text(']', 'white'));
210 210
         Console::log(Console::text('  self_ips:', 'white'));
211 211
         
212 212
         foreach ($conf['selfIps'] as $ip) {
213
-            Console::log(Console::text('    [', 'white') . Console::text($ip, 'green') . Console::text(']', 'white'));   
213
+            Console::log(Console::text('    [', 'white').Console::text($ip, 'green').Console::text(']', 'white'));   
214 214
         }
215 215
 
216 216
         Console::log();   
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
 
232 232
         $categories = ApiHandler::getCategories();
233 233
         $rowHeaders = [
234
-            Console::text('ShortName',      'darkgray') => 15, 
235
-            Console::text('Id',             'darkgray') => 2, 
236
-            Console::text('Full name',      'darkgray') => 18,
237
-            Console::text('Can be alone?',  'darkgray') => 15
234
+            Console::text('ShortName', 'darkgray') => 15, 
235
+            Console::text('Id', 'darkgray') => 2, 
236
+            Console::text('Full name', 'darkgray') => 18,
237
+            Console::text('Can be alone?', 'darkgray') => 15
238 238
         ];
239 239
         Console::$verticalSeparator = '  ';
240 240
         Console::$verticalInnerSeparator = '  ';
@@ -244,17 +244,16 @@  discard block
 block discarded – undo
244 244
         
245 245
         foreach ($categories as $cat) {
246 246
             $id = Console::text($cat[1], 'white');
247
-            $standalone = $cat[3] ? Console::text('✓', 'green') . Console::text(' true ', 'lightgray') : 
248
-                                    Console::text('✗', 'red')   . Console::text(' false', 'darkgray');
249
-            $shortName =  Console::text($cat[0], 'white');
250
-            $fullName =   Console::text($cat[2], 'lightgray');
247
+            $standalone = $cat[3] ? Console::text('✓', 'green').Console::text(' true ', 'lightgray') : Console::text('✗', 'red').Console::text(' false', 'darkgray');
248
+            $shortName = Console::text($cat[0], 'white');
249
+            $fullName = Console::text($cat[2], 'lightgray');
251 250
 
252 251
             Console::log(
253 252
                 Console::TableRowStart().  
254
-                Console::TableRowCell( $shortName , 15).  
255
-                Console::TableRowCell( $id , 2, Console::ALIGN_CENTER).  
256
-                Console::TableRowCell( $fullName , 18).  
257
-                Console::TableRowCell( $standalone , 15,  Console::ALIGN_CENTER)  
253
+                Console::TableRowCell($shortName, 15).  
254
+                Console::TableRowCell($id, 2, Console::ALIGN_CENTER).  
255
+                Console::TableRowCell($fullName, 18).  
256
+                Console::TableRowCell($standalone, 15, Console::ALIGN_CENTER)  
258 257
             );
259 258
         }
260 259
         //Console::log(Console::tableRowSeparator($rowHeaders), 'darkgray');
@@ -273,11 +272,11 @@  discard block
 block discarded – undo
273 272
      */
274 273
     protected static function reportIP(array $arguments): void
275 274
     {
276
-        $ip      = self::getArgumentValue($arguments,'R', 'report');
277
-        $cats    = self::getArgumentValue($arguments,'c', 'categories');
278
-        $message = self::getArgumentValue($arguments,'m', 'message');
275
+        $ip      = self::getArgumentValue($arguments, 'R', 'report');
276
+        $cats    = self::getArgumentValue($arguments, 'c', 'categories');
277
+        $message = self::getArgumentValue($arguments, 'm', 'message');
279 278
         
280
-        self::printTitle(Console::text('  ► Report IP: ', 'darkgray') . Console::text(escapeshellcmd($ip), 'white'));
279
+        self::printTitle(Console::text('  ► Report IP: ', 'darkgray').Console::text(escapeshellcmd($ip), 'white'));
281 280
         self::printTempMessage();
282 281
 
283 282
         // Peforms request 
@@ -288,7 +287,7 @@  discard block
 block discarded – undo
288 287
         self::clearTempMessage();
289 288
         
290 289
         // check for errors / empty response
291
-        if (self::hasErrors($report)){
290
+        if (self::hasErrors($report)) {
292 291
             self::printFooter();
293 292
             Program::exit(1);
294 293
         }
@@ -297,14 +296,14 @@  discard block
 block discarded – undo
297 296
         $score = empty($report->data->abuseConfidenceScore) ? 0 : $report->data->abuseConfidenceScore;
298 297
         $scoreColor = self::getScoreColor($score);
299 298
 
300
-        switch (self::$outputFormat){
299
+        switch (self::$outputFormat) {
301 300
             case self::OUTPUT_JSON:
302 301
                 echo json_encode($report, JSON_PRETTY_PRINT);
303 302
                 break;
304 303
        
305 304
             case self::OUTPUT_DEFAULT:  
306 305
                 Console::log(
307
-                    Console::text('   ✓', 'green').Console::text(' IP: [', 'white') .
306
+                    Console::text('   ✓', 'green').Console::text(' IP: [', 'white').
308 307
                     Console::text($ip, $scoreColor).Console::text('] successfully reported', 'white')
309 308
                 );
310 309
                 Console::log(Console::text('     Confidence score: ', 'white').self::getScoreBadge($score));
@@ -330,26 +329,26 @@  discard block
 block discarded – undo
330 329
      */
331 330
     protected static function bulkReport(array $arguments): void
332 331
     {
333
-        $fileName = self::getArgumentValue($arguments,'V', 'bulk-report');
332
+        $fileName = self::getArgumentValue($arguments, 'V', 'bulk-report');
334 333
 
335
-        self::printTitle(Console::text('  ► Bulk report for file: ', 'darkgray') . Console::text(escapeshellcmd($fileName), 'white'));
334
+        self::printTitle(Console::text('  ► Bulk report for file: ', 'darkgray').Console::text(escapeshellcmd($fileName), 'white'));
336 335
         self::printTempMessage();
337 336
 
338 337
         // Peforms request 
339 338
         $timeStart = microtime(true);  
340 339
         $response = self::$api->bulkReport($fileName)->getObject();     
341 340
         $timeEnd = microtime(true);      
342
-        $time = $timeEnd - $timeStart;  // request time
341
+        $time = $timeEnd - $timeStart; // request time
343 342
         self::clearTempMessage();
344 343
 
345 344
         // check for errors / empty response
346
-        if (self::hasErrors($response)){
345
+        if (self::hasErrors($response)) {
347 346
             self::printFooter();
348 347
             Program::exit(1);
349 348
         }
350 349
 
351 350
         // ✓ Done
352
-        switch (self::$outputFormat){
351
+        switch (self::$outputFormat) {
353 352
             case self::OUTPUT_JSON:
354 353
                 echo json_encode($response, JSON_PRETTY_PRINT);
355 354
                 break;
@@ -364,7 +363,7 @@  discard block
 block discarded – undo
364 363
 
365 364
             case self::OUTPUT_PLAINTEXT:
366 365
                 $nbSavedReports = isset($response->data->savedReports) ? $response->data->savedReports : 0;
367
-                echo $nbSavedReports . PHP_EOL;
366
+                echo $nbSavedReports.PHP_EOL;
368 367
                 break;
369 368
 
370 369
         }
@@ -381,8 +380,8 @@  discard block
 block discarded – undo
381 380
      */
382 381
     protected static function clearIP(array $arguments): void
383 382
     {
384
-        $ip = self::getArgumentValue($arguments,'E', 'clear');
385
-        self::printTitle(Console::text('  ► Clear reports for IP: ', 'darkgray') . Console::text(escapeshellcmd($ip), 'white'));
383
+        $ip = self::getArgumentValue($arguments, 'E', 'clear');
384
+        self::printTitle(Console::text('  ► Clear reports for IP: ', 'darkgray').Console::text(escapeshellcmd($ip), 'white'));
386 385
 
387 386
         // Peforms request 
388 387
         self::printTempMessage();
@@ -393,22 +392,22 @@  discard block
 block discarded – undo
393 392
         self::clearTempMessage();
394 393
 
395 394
         // check for errors / empty response
396
-        if (self::hasErrors($response)){
395
+        if (self::hasErrors($response)) {
397 396
             self::printFooter($time);
398 397
             Program::exit(1);
399 398
         }
400 399
         
401 400
         // ✓ Done: print deleted report number 
402
-        switch (self::$outputFormat){
401
+        switch (self::$outputFormat) {
403 402
             case self::OUTPUT_JSON:
404 403
                 echo json_encode($response, JSON_PRETTY_PRINT);
405 404
                 break;
406 405
        
407 406
             case self::OUTPUT_DEFAULT:  
408 407
                 Console::log(
409
-                    Console::text('   ✓', 'green') . 
410
-                    Console::text(' Successfull clear request for IP: [', 'white') .
411
-                    Console::text($ip, 'lightyellow') .
408
+                    Console::text('   ✓', 'green'). 
409
+                    Console::text(' Successfull clear request for IP: [', 'white').
410
+                    Console::text($ip, 'lightyellow').
412 411
                     Console::text(']', 'white')
413 412
                 );
414 413
                 self::printResult('     Deleted reports: ', $response->data->numReportsDeleted ?? 0, 'lightyellow');
@@ -417,7 +416,7 @@  discard block
 block discarded – undo
417 416
                 break;
418 417
 
419 418
             case self::OUTPUT_PLAINTEXT:
420
-                echo ($response->data->numReportsDeleted ?? 0) . PHP_EOL;
419
+                echo ($response->data->numReportsDeleted ?? 0).PHP_EOL;
421 420
                 break;
422 421
 
423 422
         }
@@ -437,8 +436,8 @@  discard block
 block discarded – undo
437 436
         self::printTitle(Console::text('  ► Get Blacklist ', 'darkgray'));
438 437
 
439 438
         $plainText  = (self::$outputFormat === self::OUTPUT_PLAINTEXT); 
440
-        $limit      = self::getNumericParameter($arguments,'l', 'limit', 1000);
441
-        $scoreMin   = self::getNumericParameter($arguments,'s', 'score', 100);
439
+        $limit      = self::getNumericParameter($arguments, 'l', 'limit', 1000);
440
+        $scoreMin   = self::getNumericParameter($arguments, 's', 'score', 100);
442 441
         
443 442
         self::printTempMessage();
444 443
         
@@ -453,13 +452,13 @@  discard block
 block discarded – undo
453 452
         // response could be json on error, while plaintext flag is set
454 453
         $decodedResponse = $response->getObject();
455 454
 
456
-        if (self::hasErrors($decodedResponse, false)){
455
+        if (self::hasErrors($decodedResponse, false)) {
457 456
             self::printFooter($time);
458 457
             Program::exit(1);
459 458
         }
460 459
 
461 460
         // ✓ Done: print deleted report number 
462
-        switch (self::$outputFormat){
461
+        switch (self::$outputFormat) {
463 462
             case self::OUTPUT_JSON:
464 463
                 echo json_encode($decodedResponse, JSON_PRETTY_PRINT);
465 464
                 break;
@@ -468,7 +467,7 @@  discard block
 block discarded – undo
468 467
                  // print list
469 468
                 self::printResult('  List generated at: ', self::getDate($decodedResponse->meta->generatedAt), 'lightyellow', '');
470 469
                 Console::log();
471
-                foreach ($decodedResponse->data as $report){
470
+                foreach ($decodedResponse->data as $report) {
472 471
                     $score = empty($report->abuseConfidenceScore) ? 0 : $report->abuseConfidenceScore;
473 472
                     $defaultColor = self::getScoreColor($score);
474 473
 
@@ -503,12 +502,12 @@  discard block
 block discarded – undo
503 502
      */
504 503
     protected static function checkBlock(array $arguments): void
505 504
     {
506
-        $network  = self::getArgumentValue($arguments,'K', 'check-block');
505
+        $network = self::getArgumentValue($arguments, 'K', 'check-block');
507 506
 
508
-        self::printTitle(Console::text('  ► Check network: ', 'darkgray') . Console::text(escapeshellcmd($network), 'white') . Console::text('', 'darkgray'));
507
+        self::printTitle(Console::text('  ► Check network: ', 'darkgray').Console::text(escapeshellcmd($network), 'white').Console::text('', 'darkgray'));
509 508
 
510 509
         $maxAge   = self::getNumericParameter($arguments, 'd', 'days', 30);
511
-        $limit    = self::getNumericParameter($arguments,'l', 'limit', 0); // 0 mean no limit
510
+        $limit    = self::getNumericParameter($arguments, 'l', 'limit', 0); // 0 mean no limit
512 511
 
513 512
         self::printTempMessage();
514 513
 
@@ -519,19 +518,19 @@  discard block
 block discarded – undo
519 518
         self::clearTempMessage();
520 519
 
521 520
         // check for errors / empty response
522
-        if (self::hasErrors($check)){
521
+        if (self::hasErrors($check)) {
523 522
             self::printFooter($time);
524 523
             Program::exit(1);
525 524
         }
526 525
 
527
-        switch (self::$outputFormat){
526
+        switch (self::$outputFormat) {
528 527
             case self::OUTPUT_JSON:
529 528
                 echo json_encode($check, JSON_PRETTY_PRINT);
530 529
                 break;
531 530
        
532 531
             case self::OUTPUT_DEFAULT:  
533 532
                 self::printCheckBlockDetail($check);
534
-                self::printCheckBlockReportedIP($check,$maxAge,$limit);
533
+                self::printCheckBlockReportedIP($check, $maxAge, $limit);
535 534
                 Console::log();
536 535
                 self::printFooter($time);
537 536
                 break;
@@ -540,8 +539,8 @@  discard block
 block discarded – undo
540 539
                 $nbReports = isset($check->data->reportedAddress) ? count($check->data->reportedAddress) : 0;
541 540
                 if ($nbReports > 0) {
542 541
                     $numberDiplayedReports = 0;
543
-                    foreach ($check->data->reportedAddress as $report){
544
-                        echo ($report->ipAddress) . ' ' . $report->abuseConfidenceScore . PHP_EOL;
542
+                    foreach ($check->data->reportedAddress as $report) {
543
+                        echo ($report->ipAddress).' '.$report->abuseConfidenceScore.PHP_EOL;
545 544
 
546 545
                         // counter
547 546
                         $numberDiplayedReports++;
@@ -565,14 +564,14 @@  discard block
 block discarded – undo
565 564
      */
566 565
     protected static function checkIP(array $arguments): void
567 566
     {
568
-        $ip = self::getArgumentValue($arguments,'C', 'check');
567
+        $ip = self::getArgumentValue($arguments, 'C', 'check');
569 568
         
570
-        self::printTitle(Console::text('  ► Check IP: ', 'darkgray') . Console::text(escapeshellcmd($ip), 'white') . Console::text('', 'darkgray'));
569
+        self::printTitle(Console::text('  ► Check IP: ', 'darkgray').Console::text(escapeshellcmd($ip), 'white').Console::text('', 'darkgray'));
571 570
         
572
-        $verbose            = self::inArguments($arguments,'v', 'verbose');
571
+        $verbose            = self::inArguments($arguments, 'v', 'verbose');
573 572
         $maxAge             = self::getNumericParameter($arguments, 'd', 'days', 30);
574
-        $maxReportsNumber   = self::getNumericParameter($arguments,'l', 'limit', 10);
575
-        $ip                 = self::getArgumentValue($arguments,'C', 'check');
573
+        $maxReportsNumber   = self::getNumericParameter($arguments, 'l', 'limit', 10);
574
+        $ip                 = self::getArgumentValue($arguments, 'C', 'check');
576 575
 
577 576
         self::printTempMessage();
578 577
         $timeStart = microtime(true);                                           
@@ -582,7 +581,7 @@  discard block
 block discarded – undo
582 581
         self::clearTempMessage();
583 582
 
584 583
         // check for errors / empty response
585
-        if (self::hasErrors($check)){
584
+        if (self::hasErrors($check)) {
586 585
             self::printFooter($time);
587 586
             Program::exit(1);
588 587
         }
@@ -590,7 +589,7 @@  discard block
 block discarded – undo
590 589
         // score and data color (depending of abuseConfidenceScore)
591 590
         $score = empty($check->data->abuseConfidenceScore) ? 0 : $check->data->abuseConfidenceScore;
592 591
 
593
-        switch (self::$outputFormat){
592
+        switch (self::$outputFormat) {
594 593
             case self::OUTPUT_JSON:
595 594
                 echo json_encode($check, JSON_PRETTY_PRINT);
596 595
                 break;
@@ -600,7 +599,7 @@  discard block
 block discarded – undo
600 599
                 self::printCheckScore($check);
601 600
                 self::printCheckDetail($check, $defaultColor);
602 601
                 self::printCheckReports($check, $maxAge, $defaultColor);
603
-                if ($verbose){
602
+                if ($verbose) {
604 603
                     self::printCheckLastReports($check, $maxReportsNumber);
605 604
                 }
606 605
                 Console::log();
@@ -608,7 +607,7 @@  discard block
 block discarded – undo
608 607
                 break;
609 608
 
610 609
             case self::OUTPUT_PLAINTEXT:
611
-                echo ($check->data->abuseConfidenceScore ?? 0) . PHP_EOL;
610
+                echo ($check->data->abuseConfidenceScore ?? 0).PHP_EOL;
612 611
                 break;
613 612
 
614 613
         }
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
@@ -36,17 +36,17 @@  discard block
 block discarded – undo
36 36
     /**
37 37
      * @var string      
38 38
      */
39
-    const OUTPUT_JSON       = 'json';
39
+    const OUTPUT_JSON = 'json';
40 40
 
41 41
     /**
42 42
      * @var string      
43 43
      */
44
-    const OUTPUT_DEFAULT    = 'default';
44
+    const OUTPUT_DEFAULT = 'default';
45 45
 
46 46
     /**
47 47
      * @var string      
48 48
      */
49
-    const OUTPUT_PLAINTEXT  = 'plaintext';
49
+    const OUTPUT_PLAINTEXT = 'plaintext';
50 50
     
51 51
     /**
52 52
      * @var string      $outputFormat
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     protected static function printTempMessage(): void
92 92
     {
93 93
         if (self::isDefaultOuput()) {
94
-            Console::reLog(Console::text('   ? ', 'green') . Console::text('waiting for api response', 'white') . Console::text(' ... ', 'green'));
94
+            Console::reLog(Console::text('   ? ', 'green').Console::text('waiting for api response', 'white').Console::text(' ... ', 'green'));
95 95
         }
96 96
     }
97 97
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
         self::printLogo();
146 146
 
147 147
         Console::log();
148
-        Console::log(Console::text('  Kristuff/AbuseIPDB Client version: ', 'darkgray') . Console::text(AbuseIPDBClient::VERSION, 'lightgray'));
149
-        Console::log(Console::text('  Kristuff/AbuseIPDB Core version:   ', 'darkgray') . Console::text(ApiHandler::VERSION, 'lightgray')); 
148
+        Console::log(Console::text('  Kristuff/AbuseIPDB Client version: ', 'darkgray').Console::text(AbuseIPDBClient::VERSION, 'lightgray'));
149
+        Console::log(Console::text('  Kristuff/AbuseIPDB Core version:   ', 'darkgray').Console::text(ApiHandler::VERSION, 'lightgray')); 
150 150
         Console::log(Console::text('  Released under the MIT licence', 'darkgray'));
151
-        Console::log(Console::text('  Made with ', 'darkgray') . Console::text('♥', 'red') . Console::text(' in France', 'darkgray'));
151
+        Console::log(Console::text('  Made with ', 'darkgray').Console::text('♥', 'red').Console::text(' in France', 'darkgray'));
152 152
         Console::log(
153 153
             Console::text('  © 2020-2022 Kristuff (', 'darkgray').
154 154
             Console::text('https://github.com/kristuff', 'darkgray', 'underlined').
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
     {
171 171
         if (self::isDefaultOuput()) {
172 172
             Console::log();    
173
-            Console::log( Console::text(' Kristuff/AbuseIPDB-client ', 'darkgray') . Console::text(' ' . AbuseIPDBClient::VERSION . ' ', 'white', 'blue')); 
174
-            Console::log(Console::text(' Made with ', 'darkgray') . Console::text('♥', 'red') . Console::text(' in France', 'darkgray')); 
173
+            Console::log(Console::text(' Kristuff/AbuseIPDB-client ', 'darkgray').Console::text(' '.AbuseIPDBClient::VERSION.' ', 'white', 'blue')); 
174
+            Console::log(Console::text(' Made with ', 'darkgray').Console::text('♥', 'red').Console::text(' in France', 'darkgray')); 
175 175
             Console::log(Console::text(' © 2020-2022 Kristuff (', 'darkgray').
176 176
                 Console::text('https://github.com/kristuff', 'darkgray', 'underlined').
177 177
                 Console::text(')', 'darkgray')
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
     protected static function printFooter($requestTime = ''): void
192 192
     {
193 193
         if (self::isDefaultOuput()) {
194
-            if (!empty($requestTime)){
194
+            if (!empty($requestTime)) {
195 195
                 $date_utc = new \DateTime("now", new \DateTimeZone("UTC"));
196 196
                 Console::log(
197
-                    Console::text('  Request time: ', 'darkgray') . Console::text($requestTime . 's', 'lightgray'). 
198
-                    Console::text(' | UTC time: ', 'darkgray') . Console::text($date_utc->format('Y-m-d H:i:s'), 'lightgray')
197
+                    Console::text('  Request time: ', 'darkgray').Console::text($requestTime.'s', 'lightgray'). 
198
+                    Console::text(' | UTC time: ', 'darkgray').Console::text($date_utc->format('Y-m-d H:i:s'), 'lightgray')
199 199
                 );
200 200
             }
201 201
             Console::log(Console::text('  ------------------------------------------------------------------------------------------------------', 'darkgray')); 
202 202
             Console::log(
203
-                Console::text('  Kristuff\AbuseIPDB ', 'darkgray') . 
204
-                Console::text(AbuseIPDBClient::VERSION, 'lightgray') . 
205
-                Console::text(' | Made with ', 'darkgray') . 
206
-                Console::text('♥', 'red') .
203
+                Console::text('  Kristuff\AbuseIPDB ', 'darkgray'). 
204
+                Console::text(AbuseIPDBClient::VERSION, 'lightgray'). 
205
+                Console::text(' | Made with ', 'darkgray'). 
206
+                Console::text('♥', 'red').
207 207
                 Console::text(' in France | © 2020-2022 Kristuff (https://github.com/kristuff)', 'darkgray')
208 208
             ); 
209 209
             Console::log(); 
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
     protected static function printResult($text, $value, string $foregroundColor = 'lightred', string $backgroundColor = '', bool $print = true): string
222 222
     {
223 223
         // do not print null/blank values
224
-        if (isset($value)){
225
-            $line = Console::text($text, 'white') . Console::text($value, $foregroundColor, $backgroundColor); 
226
-            if ($print && self::isDefaultOuput()){
224
+        if (isset($value)) {
225
+            $line = Console::text($text, 'white').Console::text($value, $foregroundColor, $backgroundColor); 
226
+            if ($print && self::isDefaultOuput()) {
227 227
                 Console::log($line);
228 228
             }
229 229
             return $line;
@@ -247,16 +247,16 @@  discard block
 block discarded – undo
247 247
         $scoreforegroundColor = 'white';
248 248
         $scoreBackgroundColor = 'green';
249 249
 
250
-        if (intval($score) > 0 ){
250
+        if (intval($score) > 0) {
251 251
             $scoreforegroundColor = 'black';
252 252
             $scoreBackgroundColor = 'yellow';
253 253
         } 
254
-        if (intval($score) > 50 ){
254
+        if (intval($score) > 50) {
255 255
             $scoreforegroundColor = 'white';
256 256
             $scoreBackgroundColor = 'red';
257 257
         } 
258 258
   
259
-        $badge = str_pad(strval($score), 3, ' ',STR_PAD_LEFT); 
259
+        $badge = str_pad(strval($score), 3, ' ', STR_PAD_LEFT); 
260 260
         return Console::text($padding.$badge.$padding, $scoreforegroundColor, $scoreBackgroundColor);
261 261
     }
262 262
 }
263 263
\ No newline at end of file
Please login to merge, or discard this patch.
src/AbstractClient.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     /**
37 37
      * @var array      
38 38
      */
39
-    const LONG_ARGUMENTS = ['output:', 'config', 'list', 'blacklist', 'check:', 'check-block:', 'days:', 'report:', 'categories:', 'message:', 'limit:', 'clear:',' bulk-report:', 'help', 'verbose', 'score:', 'version', 'timeout:'];
39
+    const LONG_ARGUMENTS = ['output:', 'config', 'list', 'blacklist', 'check:', 'check-block:', 'days:', 'report:', 'categories:', 'message:', 'limit:', 'clear:', ' bulk-report:', 'help', 'verbose', 'score:', 'version', 'timeout:'];
40 40
     
41 41
     /**
42 42
      * @var string
@@ -57,22 +57,22 @@  discard block
 block discarded – undo
57 57
      * @var array
58 58
      */
59 59
     protected static $basicCommands = [
60
-        ['h',           'help',         'printHelp'],
61
-        ['version',     'version',      'printVersion'],    // no short arg
62
-        ['L',           'list',         'printCategories'],
60
+        ['h', 'help', 'printHelp'],
61
+        ['version', 'version', 'printVersion'], // no short arg
62
+        ['L', 'list', 'printCategories'],
63 63
     ];
64 64
     
65 65
     /**
66 66
      * @var array
67 67
      */
68 68
     protected static $mainCommands = [
69
-        ['G',           'config',       'printConfig'], // require handler 
70
-        ['C',           'check',        'checkIP'],
71
-        ['K',           'check-block',  'checkBlock'],
72
-        ['R',           'report',       'reportIP'],
73
-        ['V',           'bulk-report',  'bulkReport'],
74
-        ['B',           'blacklist',    'getBlacklist'],
75
-        ['E',           'clear',        'clearIP'],
69
+        ['G', 'config', 'printConfig'], // require handler 
70
+        ['C', 'check', 'checkIP'],
71
+        ['K', 'check-block', 'checkBlock'],
72
+        ['R', 'report', 'reportIP'],
73
+        ['V', 'bulk-report', 'bulkReport'],
74
+        ['B', 'blacklist', 'getBlacklist'],
75
+        ['E', 'clear', 'clearIP'],
76 76
     ];
77 77
 
78 78
     /**
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
      */
87 87
     protected static function parseCommand(array $arguments): bool
88 88
     {
89
-        foreach(self::$basicCommands as $cmd){
90
-            if (self::inArguments($arguments, $cmd[0], $cmd[1])){
89
+        foreach (self::$basicCommands as $cmd) {
90
+            if (self::inArguments($arguments, $cmd[0], $cmd[1])) {
91 91
                 call_user_func(__NAMESPACE__.'\AbuseIPDBClient::'.$cmd[2], null);
92 92
                 return true;
93 93
             }
94 94
         }
95
-        foreach(self::$mainCommands as $cmd){
96
-            if (self::inArguments($arguments, $cmd[0], $cmd[1])){
95
+        foreach (self::$mainCommands as $cmd) {
96
+            if (self::inArguments($arguments, $cmd[0], $cmd[1])) {
97 97
                 self::createHandler($arguments);
98 98
                 self::setOutputFormat($arguments);                    
99 99
                 call_user_func(__NAMESPACE__.'\AbuseIPDBClient::'.$cmd[2], $arguments);
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
     protected static function createHandler(array $arguments): void
133 133
     {
134 134
         try {
135
-            $mainConfPath  = self::$configPath . DIRECTORY_SEPARATOR . 'conf.ini';
136
-            $localConfPath = self::$configPath . DIRECTORY_SEPARATOR . 'local.ini';
135
+            $mainConfPath  = self::$configPath.DIRECTORY_SEPARATOR.'conf.ini';
136
+            $localConfPath = self::$configPath.DIRECTORY_SEPARATOR.'local.ini';
137 137
 
138 138
             // Check main file exists and is readable
139 139
             // Even if a local file exists, main file must be here (throws ex otherwise)
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
 
143 143
             $selfIps = self::extractSelfIpsFromConf($mainConfigArray, $localConfigArray);
144 144
             $apiKey  = self::extractApiKeyFromConf($mainConfigArray, $localConfigArray);
145
-            $timeout = self::extractNumericFromConf('timeout',$mainConfigArray, $localConfigArray, 0);
145
+            $timeout = self::extractNumericFromConf('timeout', $mainConfigArray, $localConfigArray, 0);
146 146
             
147 147
             // look into arguments for possible overwrite for timeout 
148
-            if (self::inArguments($arguments, 't', 'timeout')){
148
+            if (self::inArguments($arguments, 't', 'timeout')) {
149 149
                 $timeout = self::getArgumentValue($arguments, 't', 'timeout');
150 150
             }
151 151
 
152
-            if (!is_numeric($timeout)){
152
+            if (!is_numeric($timeout)) {
153 153
                 throw new \RuntimeException('Invalid timeout argument, must be numeric.');
154 154
             }            
155 155
 
156
-            self::$api =  new QuietApiHandler($apiKey, $selfIps, intval($timeout));
156
+            self::$api = new QuietApiHandler($apiKey, $selfIps, intval($timeout));
157 157
         } catch (\Exception $e) {
158 158
             self::error($e->getMessage());
159 159
             self::printFooter();
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
      */
174 174
     protected static function extractSelfIpsFromConf(array $conf, array $localConf): array
175 175
     {
176
-        if (array_key_exists('self_ips', $localConf) && !empty($localConf['self_ips'])){
176
+        if (array_key_exists('self_ips', $localConf) && !empty($localConf['self_ips'])) {
177 177
             return array_map('trim', explode(',', $localConf['self_ips']));
178 178
         }
179
-        if (array_key_exists('self_ips', $conf) && !empty($conf['self_ips'])){
179
+        if (array_key_exists('self_ips', $conf) && !empty($conf['self_ips'])) {
180 180
             return array_map('trim', explode(',', $conf['self_ips']));
181 181
         }
182 182
         return [];
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
     {
198 198
         $key = '';
199 199
 
200
-        if (array_key_exists('api_key', $localConf)){
200
+        if (array_key_exists('api_key', $localConf)) {
201 201
             $key = $localConf['api_key'];
202 202
         }
203 203
         
204
-        if (empty($key) && array_key_exists('api_key', $conf)){
204
+        if (empty($key) && array_key_exists('api_key', $conf)) {
205 205
             $key = $conf['api_key'];
206 206
         }
207 207
 
208
-        if (empty($key)){
208
+        if (empty($key)) {
209 209
             throw new \RuntimeException('Api key is missing.');
210 210
         }
211 211
 
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
      */
227 227
     protected static function extractNumericFromConf(string $key, array $conf, array $localConf, int $default): int
228 228
     {
229
-        if (array_key_exists($key, $localConf) && is_numeric($localConf[$key])){
229
+        if (array_key_exists($key, $localConf) && is_numeric($localConf[$key])) {
230 230
             return intval($localConf[$key]);
231 231
         }
232 232
         
233
-        if (array_key_exists($key, $conf) && is_numeric($conf[$key])){
233
+        if (array_key_exists($key, $conf) && is_numeric($conf[$key])) {
234 234
             return intval($conf[$key]);
235 235
         }
236 236
 
@@ -250,21 +250,21 @@  discard block
 block discarded – undo
250 250
      */
251 251
     protected static function loadConfigFile(string $path, bool $mandatory = false): array
252 252
     {
253
-        if (file_exists($path) && is_file($path)){
253
+        if (file_exists($path) && is_file($path)) {
254 254
 
255 255
             // If main file or a local file is not readable then throws ex.
256
-            if (!is_readable($path)){
256
+            if (!is_readable($path)) {
257 257
                 throw new \RuntimeException('The configuration file ['.$path.'] is not readable.');
258 258
             }
259 259
 
260
-            $conf = parse_ini_file($path, false);  // load without sections...
261
-            if ($conf === false){
260
+            $conf = parse_ini_file($path, false); // load without sections...
261
+            if ($conf === false) {
262 262
                 throw new \RuntimeException('Unable to read configuration file ['.$path.'].');
263 263
             }
264 264
             return $conf;
265 265
         }
266 266
 
267
-        if ($mandatory){
267
+        if ($mandatory) {
268 268
             throw new \RuntimeException('The configuration file ['.$path.'] does not exist.');
269 269
         }
270 270
         return [];
Please login to merge, or discard this patch.