Passed
Branch dev (5a99cc)
by Kris
01:42
created
src/ErrorsTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     protected static function printPlainTextErrors(object $response)
38 38
     {
39
-        foreach ($response->errors as $err){
39
+        foreach ($response->errors as $err) {
40 40
             $text = 'Error: ';
41 41
             $text .= self::getErrorDetail($err, 'title');
42 42
             $text .= self::getErrorDetail($err, 'statuts');
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
      */
60 60
     private static function getErrorDetail(object $error, string $field, ?string $parent = null)
61 61
     {
62
-        if (!empty($parent)){
63
-            return  !empty($error->$parent) && !empty($error->$parent->$field) ? ' ' . $field . ': ' . $error->$parent->$field : '';
62
+        if (!empty($parent)) {
63
+            return  !empty($error->$parent) && !empty($error->$parent->$field) ? ' '.$field.': '.$error->$parent->$field : '';
64 64
         }
65 65
 
66
-        return !empty($error->$field) ? ' ' . $field . ': ' . $error->$field : '';
66
+        return !empty($error->$field) ? ' '.$field.': '.$error->$field : '';
67 67
     }
68 68
 
69 69
 }
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
src/ShellUtils.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     protected static function printTempMessage()
83 83
     {
84 84
         if (self::isDefaultOuput()) {
85
-            Console::reLog(Console::text('   ? ', 'green') . Console::text('waiting for api response', 'white') . Console::text(' ... ', 'green'));
85
+            Console::reLog(Console::text('   ? ', 'green').Console::text('waiting for api response', 'white').Console::text(' ... ', 'green'));
86 86
         }
87 87
     }
88 88
 
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
         self::printLogo();
141 141
 
142 142
         Console::log();
143
-        Console::log(Console::text('  Kristuff/AbuseIPDB Client version: ', 'darkgray') . Console::text(AbuseIPDBClient::VERSION, 'lightgray'));
144
-        Console::log(Console::text('  Kristuff/AbuseIPDB Core version:   ', 'darkgray') . Console::text(ApiHandler::VERSION, 'lightgray')); 
143
+        Console::log(Console::text('  Kristuff/AbuseIPDB Client version: ', 'darkgray').Console::text(AbuseIPDBClient::VERSION, 'lightgray'));
144
+        Console::log(Console::text('  Kristuff/AbuseIPDB Core version:   ', 'darkgray').Console::text(ApiHandler::VERSION, 'lightgray')); 
145 145
         Console::log(Console::text('  --------------------------------------------------', 'darkgray'));    
146 146
         Console::log(Console::text('  Released under the MIT licence', 'darkgray'));
147
-        Console::log(Console::text('  Made with ', 'darkgray') . Console::text('♥', 'red') . Console::text(' in France', 'darkgray'));
147
+        Console::log(Console::text('  Made with ', 'darkgray').Console::text('♥', 'red').Console::text(' in France', 'darkgray'));
148 148
         Console::log(
149 149
             Console::text('  © 2020-2021 Kristuff (', 'darkgray').
150 150
             Console::text('https://github.com/kristuff', 'darkgray', 'underlined').
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
     {
167 167
         if (self::isDefaultOuput()) {
168 168
             Console::log();    
169
-            Console::log( Console::text(' Kristuff\AbuseIPDB ', 'darkgray') . Console::text(' ' . AbuseIPDBClient::VERSION . ' ', 'white', 'blue')); 
170
-            Console::log(Console::text(' Made with ', 'darkgray') . Console::text('♥', 'red') . Console::text(' in France', 'darkgray')); 
169
+            Console::log(Console::text(' Kristuff\AbuseIPDB ', 'darkgray').Console::text(' '.AbuseIPDBClient::VERSION.' ', 'white', 'blue')); 
170
+            Console::log(Console::text(' Made with ', 'darkgray').Console::text('♥', 'red').Console::text(' in France', 'darkgray')); 
171 171
             Console::log(' © 2020-2021 Kristuff', 'darkgray'); 
172 172
             Console::log();  
173 173
         }  
@@ -184,19 +184,19 @@  discard block
 block discarded – undo
184 184
     protected static function printFooter(string $requestTime = '')
185 185
     {
186 186
         if (self::isDefaultOuput()) {
187
-            if (!empty($requestTime)){
187
+            if (!empty($requestTime)) {
188 188
                 $date_utc = new \DateTime("now", new \DateTimeZone("UTC"));
189 189
                 Console::log(
190
-                    Console::text('  Request time: ', 'darkgray') . Console::text($requestTime . 's', 'lightgray'). 
191
-                    Console::text(' | UTC time: ', 'darkgray') . Console::text($date_utc->format('Y-m-d H:i:s'), 'lightgray')
190
+                    Console::text('  Request time: ', 'darkgray').Console::text($requestTime.'s', 'lightgray'). 
191
+                    Console::text(' | UTC time: ', 'darkgray').Console::text($date_utc->format('Y-m-d H:i:s'), 'lightgray')
192 192
                 );
193 193
             }
194 194
             Console::log(Console::text('  ------------------------------------------------------------------------------------------------------', 'darkgray')); 
195 195
             Console::log(
196
-                Console::text('  Kristuff\AbuseIPDB ', 'darkgray') . 
197
-                Console::text(AbuseIPDBClient::VERSION, 'lightgray') . 
198
-                Console::text(' | Made with ', 'darkgray') . 
199
-                Console::text('♥', 'red') .
196
+                Console::text('  Kristuff\AbuseIPDB ', 'darkgray'). 
197
+                Console::text(AbuseIPDBClient::VERSION, 'lightgray'). 
198
+                Console::text(' | Made with ', 'darkgray'). 
199
+                Console::text('♥', 'red').
200 200
                 Console::text(' in France | © 2020-2021 Kristuff (https://github.com/kristuff)', 'darkgray')
201 201
             ); 
202 202
             Console::log(); 
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
     {
216 216
         
217 217
         // do not print null/blank values
218
-        if (isset($value)){
219
-            $line = Console::text($text, 'white') . Console::text($value, $foregroundColor, $backgroundColor); 
220
-            if ($print && self::isDefaultOuput()){
218
+        if (isset($value)) {
219
+            $line = Console::text($text, 'white').Console::text($value, $foregroundColor, $backgroundColor); 
220
+            if ($print && self::isDefaultOuput()) {
221 221
                 Console::log($line);
222 222
             }
223 223
             return $line;
@@ -241,16 +241,16 @@  discard block
 block discarded – undo
241 241
         $scoreforegroundColor = 'white';
242 242
         $scoreBackgroundColor = 'green';
243 243
 
244
-        if (intval($score) > 0 ){
244
+        if (intval($score) > 0) {
245 245
             $scoreforegroundColor = 'black';
246 246
             $scoreBackgroundColor = 'yellow';
247 247
         } 
248
-        if (intval($score) > 50 ){
248
+        if (intval($score) > 50) {
249 249
             $scoreforegroundColor = 'white';
250 250
             $scoreBackgroundColor = 'red';
251 251
         } 
252 252
   
253
-        $badge = str_pad($score, 3, ' ',STR_PAD_LEFT); 
253
+        $badge = str_pad($score, 3, ' ', STR_PAD_LEFT); 
254 254
         return Console::text($padding.$badge.$padding, $scoreforegroundColor, $scoreBackgroundColor);
255 255
     }
256 256
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      * 
265 265
      * @return bool     
266 266
      */
267
-    protected static function hasErrors(object $response, bool $checkForEmpty = true )
267
+    protected static function hasErrors(object $response, bool $checkForEmpty = true)
268 268
     {
269 269
         return $checkForEmpty ? self::parseErrors($response) || self::checkForEmpty($response) : self::parseErrors($response);
270 270
     }
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
      */
282 282
     private static function parseErrors(object $response)
283 283
     {
284
-        if (isset($response) && isset($response->errors)){
285
-            switch (self::$outputFormat){
284
+        if (isset($response) && isset($response->errors)) {
285
+            switch (self::$outputFormat) {
286 286
                 case self::OUTPUT_DEFAULT:
287 287
                     self::printFormattedErrors($response);
288 288
                     break;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
     protected static function checkForEmpty(object $response)
313 313
     {
314 314
         // check for empty response ?
315
-        if ( empty($response) || empty($response->data) ){
315
+        if (empty($response) || empty($response->data)) {
316 316
             self::error('An unexpected error occurred.');
317 317
             return true;
318 318
         }
@@ -330,24 +330,24 @@  discard block
 block discarded – undo
330 330
     protected static function printFormattedErrors(object $response)
331 331
     {
332 332
         // top error badge    
333
-        Console::log('  ' .   Console::text(' ERROR ','white', 'red'));
333
+        Console::log('  '.Console::text(' ERROR ', 'white', 'red'));
334 334
 
335 335
         $num = 0;
336 336
         // errors is an array, could have more than one error..
337
-        foreach ($response->errors as $err){
337
+        foreach ($response->errors as $err) {
338 338
             $num++;
339 339
 
340
-            Console::log(Console::text('   ✗', 'red') .  self::printResult(' Number:    ', $num, 'lightyellow','', false));
341
-            self::printResult('     Status:    ', $err->status ?? null, 'lightyellow','');    
340
+            Console::log(Console::text('   ✗', 'red').self::printResult(' Number:    ', $num, 'lightyellow', '', false));
341
+            self::printResult('     Status:    ', $err->status ?? null, 'lightyellow', '');    
342 342
             
343
-            if (!empty($err->source) && !empty($err->source->parameter)){
343
+            if (!empty($err->source) && !empty($err->source->parameter)) {
344 344
                 self::printResult('     Parameter: ', $err->source->parameter, 'lightyellow');    
345 345
             }
346 346
             self::printResult('     Title:     ', $err->title ?? null, 'lightyellow');    
347 347
             self::printResult('     Detail:    ', $err->detail ?? null, 'lightyellow');    
348 348
 
349 349
             // separate errors
350
-            if (count($response->errors) > 1){
350
+            if (count($response->errors) > 1) {
351 351
                 Console::log('   ---');
352 352
             }
353 353
         }
@@ -367,11 +367,11 @@  discard block
 block discarded – undo
367 367
     {
368 368
         if (self::isDefaultOuput()) {
369 369
             // ✗
370
-            Console::log('  ' .   Console::text(' ERROR ','white', 'red'));
370
+            Console::log('  '.Console::text(' ERROR ', 'white', 'red'));
371 371
             Console::log(
372
-                Console::text('   ✗', 'red') . 
373
-                Console::text(' Detail:    ', 'white') . 
374
-                Console::text($error, 'lightyellow') . 
372
+                Console::text('   ✗', 'red'). 
373
+                Console::text(' Detail:    ', 'white'). 
374
+                Console::text($error, 'lightyellow'). 
375 375
                 Console::text('', 'white')
376 376
             );    
377 377
             Console::log();
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
      */
392 392
     protected static function validate(bool $condition, string $message, bool $print = true)
393 393
     {
394
-        if ( !$condition ){
394
+        if (!$condition) {
395 395
             if ($print && self::isDefaultOuput()) {
396 396
                 Console::log();
397 397
                 self::error($message);
@@ -415,10 +415,10 @@  discard block
 block discarded – undo
415 415
      */
416 416
     protected static function getNumericParameter(array $arguments, string $shortArg, string $longArg, int $defaultValue)
417 417
     {
418
-         if (self::inArguments($arguments,$shortArg, $longArg)){
419
-            $val = self::getArgumentValue($arguments,$shortArg, $longArg);
418
+         if (self::inArguments($arguments, $shortArg, $longArg)) {
419
+            $val = self::getArgumentValue($arguments, $shortArg, $longArg);
420 420
 
421
-            if (!is_numeric($val)){
421
+            if (!is_numeric($val)) {
422 422
                 self::error("Invalid parameter: $longArg must be a numeric value.");
423 423
                 self::printFooter();
424 424
                 Program::exit(1);
Please login to merge, or discard this patch.