@@ -145,7 +145,7 @@ discard block  | 
                                                    ||
| 145 | 145 | */  | 
                                                        
| 146 | 146 | public function report(string $ip = '', string $categories = '', string $message = '', bool $returnArray = false)  | 
                                                        
| 147 | 147 |      { | 
                                                        
| 148 | - // ip must be set  | 
                                                        |
| 148 | + // ip must be set  | 
                                                        |
| 149 | 149 |          if (empty($ip)){ | 
                                                        
| 150 | 150 |              throw new \InvalidArgumentException('Ip was empty'); | 
                                                        
| 151 | 151 | }  | 
                                                        
@@ -156,7 +156,7 @@ discard block  | 
                                                    ||
| 156 | 156 | }  | 
                                                        
| 157 | 157 | |
| 158 | 158 | // message must be set  | 
                                                        
| 159 | -          if (empty($message)){ | 
                                                        |
| 159 | +            if (empty($message)){ | 
                                                        |
| 160 | 160 |              throw new \InvalidArgumentException('report message was empty'); | 
                                                        
| 161 | 161 | }  | 
                                                        
| 162 | 162 | |
@@ -275,7 +275,7 @@ discard block  | 
                                                    ||
| 275 | 275 | |
| 276 | 276 | // option  | 
                                                        
| 277 | 277 |          if ($verbose){ | 
                                                        
| 278 | - $data['verbose'] = true;  | 
                                                        |
| 278 | + $data['verbose'] = true;  | 
                                                        |
| 279 | 279 | }  | 
                                                        
| 280 | 280 | |
| 281 | 281 |          $response = $this->apiRequest('check', $data, 'GET') ; | 
                                                        
@@ -283,7 +283,7 @@ discard block  | 
                                                    ||
| 283 | 283 | return json_decode($response, $returnArray);  | 
                                                        
| 284 | 284 | }  | 
                                                        
| 285 | 285 | |
| 286 | - /**  | 
                                                        |
| 286 | + /**  | 
                                                        |
| 287 | 287 | * Perform a 'clear-address' api request  | 
                                                        
| 288 | 288 | *  | 
                                                        
| 289 | 289 | * Sample response:  | 
                                                        
@@ -457,14 +457,14 @@ discard block  | 
                                                    ||
| 457 | 457 | 'Key: ' . $this->aipdbApiKey,  | 
                                                        
| 458 | 458 | ]);  | 
                                                        
| 459 | 459 | |
| 460 | - // execute curl call  | 
                                                        |
| 461 | - $result = curl_exec($ch);  | 
                                                        |
| 460 | + // execute curl call  | 
                                                        |
| 461 | + $result = curl_exec($ch);  | 
                                                        |
| 462 | 462 | |
| 463 | - // close connection  | 
                                                        |
| 464 | - curl_close($ch);  | 
                                                        |
| 463 | + // close connection  | 
                                                        |
| 464 | + curl_close($ch);  | 
                                                        |
| 465 | 465 | |
| 466 | - // return response as is (JSON or plain text)  | 
                                                        |
| 467 | - return $result;  | 
                                                        |
| 466 | + // return response as is (JSON or plain text)  | 
                                                        |
| 467 | + return $result;  | 
                                                        |
| 468 | 468 | }  | 
                                                        
| 469 | 469 | |
| 470 | 470 | /**  | 
                                                        
@@ -475,7 +475,7 @@ discard block  | 
                                                    ||
| 475 | 475 | * @access public  | 
                                                        
| 476 | 476 | * @param string $message The original message  | 
                                                        
| 477 | 477 | *  | 
                                                        
| 478 | - * @return string  | 
                                                        |
| 478 | + * @return string  | 
                                                        |
| 479 | 479 | */  | 
                                                        
| 480 | 480 | protected function cleanMessage(string $message)  | 
                                                        
| 481 | 481 |      { | 
                                                        
@@ -500,10 +500,10 @@ discard block  | 
                                                    ||
| 500 | 500 | *  | 
                                                        
| 501 | 501 | * @access public  | 
                                                        
| 502 | 502 | * @static  | 
                                                        
| 503 | - * @param string $filePath The file's full path  | 
                                                        |
| 504 | - * @param bool $throwError Throw error on true or silent process. Default is true  | 
                                                        |
| 503 | + * @param string $filePath The file's full path  | 
                                                        |
| 504 | + * @param bool $throwError Throw error on true or silent process. Default is true  | 
                                                        |
| 505 | 505 | *  | 
                                                        
| 506 | - * @return object|null  | 
                                                        |
| 506 | + * @return object|null  | 
                                                        |
| 507 | 507 | * @throws \Exception  | 
                                                        
| 508 | 508 | * @throws \LogicException  | 
                                                        
| 509 | 509 | */  | 
                                                        
@@ -511,10 +511,10 @@ discard block  | 
                                                    ||
| 511 | 511 |      { | 
                                                        
| 512 | 512 | // check file exists  | 
                                                        
| 513 | 513 |          if (!file_exists($filePath) || !is_file($filePath)){ | 
                                                        
| 514 | -           if ($throwError) { | 
                                                        |
| 514 | +            if ($throwError) { | 
                                                        |
| 515 | 515 |                  throw new \Exception('Config file not found'); | 
                                                        
| 516 | - }  | 
                                                        |
| 517 | - return null;  | 
                                                        |
| 516 | + }  | 
                                                        |
| 517 | + return null;  | 
                                                        |
| 518 | 518 | }  | 
                                                        
| 519 | 519 | |
| 520 | 520 | // get and parse content  | 
                                                        
@@ -50,7 +50,7 @@ discard block  | 
                                                    ||
| 50 | 50 | * @access protected  | 
                                                        
| 51 | 51 | * @var array $selfIps  | 
                                                        
| 52 | 52 | */  | 
                                                        
| 53 | - protected $selfIps = [];  | 
                                                        |
| 53 | + protected $selfIps = [ ];  | 
                                                        |
| 54 | 54 | |
| 55 | 55 | /**  | 
                                                        
| 56 | 56 | * Constructor  | 
                                                        
@@ -61,7 +61,7 @@ discard block  | 
                                                    ||
| 61 | 61 | * @param array $myIps The Ips/domain name you dont want to display in report messages  | 
                                                        
| 62 | 62 | *  | 
                                                        
| 63 | 63 | */  | 
                                                        
| 64 | - public function __construct(string $apiKey, string $userId, array $myIps = [])  | 
                                                        |
| 64 | + public function __construct(string $apiKey, string $userId, array $myIps = [ ])  | 
                                                        |
| 65 | 65 |      { | 
                                                        
| 66 | 66 | $this->aipdbApiKey = $apiKey;  | 
                                                        
| 67 | 67 | $this->aipdbUserId = $userId;  | 
                                                        
@@ -100,21 +100,21 @@ discard block  | 
                                                    ||
| 100 | 100 |      { | 
                                                        
| 101 | 101 | |
| 102 | 102 | // check file exists  | 
                                                        
| 103 | -        if (!file_exists($configPath) || !is_file($configPath)){ | 
                                                        |
| 103 | +        if (!file_exists($configPath) || !is_file($configPath)) { | 
                                                        |
| 104 | 104 |              throw new \InvalidArgumentException('The file [' . $configPath . '] does not exist.'); | 
                                                        
| 105 | 105 | }  | 
                                                        
| 106 | 106 | |
| 107 | 107 | // check file is readable  | 
                                                        
| 108 | -        if (!is_readable($configPath)){ | 
                                                        |
| 108 | +        if (!is_readable($configPath)) { | 
                                                        |
| 109 | 109 |              throw new InvalidPermissionException('The file [' . $configPath . '] is not readable.'); | 
                                                        
| 110 | 110 | }  | 
                                                        
| 111 | 111 | |
| 112 | 112 | $keyConfig = self::loadJsonFile($configPath);  | 
                                                        
| 113 | - $selfIps = [];  | 
                                                        |
| 113 | + $selfIps = [ ];  | 
                                                        |
| 114 | 114 | |
| 115 | 115 | // Look for other optional config files in the same directory  | 
                                                        
| 116 | 116 | $selfIpsConfigPath = pathinfo($configPath, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . 'self_ips.json';  | 
                                                        
| 117 | -        if (file_exists($selfIpsConfigPath)){ | 
                                                        |
| 117 | +        if (file_exists($selfIpsConfigPath)) { | 
                                                        |
| 118 | 118 | $selfIps = self::loadJsonFile($selfIpsConfigPath)->self_ips;  | 
                                                        
| 119 | 119 | }  | 
                                                        
| 120 | 120 | |
@@ -146,17 +146,17 @@ discard block  | 
                                                    ||
| 146 | 146 | public function report(string $ip = '', string $categories = '', string $message = '', bool $returnArray = false)  | 
                                                        
| 147 | 147 |      { | 
                                                        
| 148 | 148 | // ip must be set  | 
                                                        
| 149 | -        if (empty($ip)){ | 
                                                        |
| 149 | +        if (empty($ip)) { | 
                                                        |
| 150 | 150 |              throw new \InvalidArgumentException('Ip was empty'); | 
                                                        
| 151 | 151 | }  | 
                                                        
| 152 | 152 | |
| 153 | 153 | // categories must be set  | 
                                                        
| 154 | -        if (empty($categories)){ | 
                                                        |
| 154 | +        if (empty($categories)) { | 
                                                        |
| 155 | 155 |              throw new \InvalidArgumentException('categories list was empty'); | 
                                                        
| 156 | 156 | }  | 
                                                        
| 157 | 157 | |
| 158 | 158 | // message must be set  | 
                                                        
| 159 | -          if (empty($message)){ | 
                                                        |
| 159 | +          if (empty($message)) { | 
                                                        |
| 160 | 160 |              throw new \InvalidArgumentException('report message was empty'); | 
                                                        
| 161 | 161 | }  | 
                                                        
| 162 | 162 | |
@@ -223,12 +223,12 @@ discard block  | 
                                                    ||
| 223 | 223 | public function checkBlock(string $network = null, int $maxAge = 30, bool $returnArray = false)  | 
                                                        
| 224 | 224 |      { | 
                                                        
| 225 | 225 | // max age must be less or equal to 365  | 
                                                        
| 226 | -        if ($maxAge > 365 || $maxAge < 1){ | 
                                                        |
| 226 | +        if ($maxAge > 365 || $maxAge < 1) { | 
                                                        |
| 227 | 227 |              throw new \InvalidArgumentException('maxAge must be at least 1 and less than 365 (' . $maxAge . ' was given)'); | 
                                                        
| 228 | 228 | }  | 
                                                        
| 229 | 229 | |
| 230 | 230 | // ip must be set  | 
                                                        
| 231 | -        if (empty($network)){ | 
                                                        |
| 231 | +        if (empty($network)) { | 
                                                        |
| 232 | 232 |              throw new \InvalidArgumentException('network argument must be set (null given)'); | 
                                                        
| 233 | 233 | }  | 
                                                        
| 234 | 234 | |
@@ -238,7 +238,7 @@ discard block  | 
                                                    ||
| 238 | 238 | 'maxAgeInDays' => $maxAge,  | 
                                                        
| 239 | 239 | ];  | 
                                                        
| 240 | 240 | |
| 241 | -        $response = $this->apiRequest('check-block', $data, 'GET') ; | 
                                                        |
| 241 | +        $response = $this->apiRequest('check-block', $data, 'GET'); | 
                                                        |
| 242 | 242 | |
| 243 | 243 | return json_decode($response, $returnArray);  | 
                                                        
| 244 | 244 | }  | 
                                                        
@@ -258,12 +258,12 @@ discard block  | 
                                                    ||
| 258 | 258 | public function check(string $ip = null, int $maxAge = 30, bool $verbose = false, bool $returnArray = false)  | 
                                                        
| 259 | 259 |      { | 
                                                        
| 260 | 260 | // max age must be less or equal to 365  | 
                                                        
| 261 | -        if ($maxAge > 365 || $maxAge < 1){ | 
                                                        |
| 261 | +        if ($maxAge > 365 || $maxAge < 1) { | 
                                                        |
| 262 | 262 |              throw new \InvalidArgumentException('maxAge must be at least 1 and less than 365 (' . $maxAge . ' was given)'); | 
                                                        
| 263 | 263 | }  | 
                                                        
| 264 | 264 | |
| 265 | 265 | // ip must be set  | 
                                                        
| 266 | -        if (empty($ip)){ | 
                                                        |
| 266 | +        if (empty($ip)) { | 
                                                        |
| 267 | 267 |              throw new \InvalidArgumentException('ip argument must be set (null given)'); | 
                                                        
| 268 | 268 | }  | 
                                                        
| 269 | 269 | |
@@ -274,11 +274,11 @@ discard block  | 
                                                    ||
| 274 | 274 | ];  | 
                                                        
| 275 | 275 | |
| 276 | 276 | // option  | 
                                                        
| 277 | -        if ($verbose){ | 
                                                        |
| 278 | - $data['verbose'] = true;  | 
                                                        |
| 277 | +        if ($verbose) { | 
                                                        |
| 278 | + $data[ 'verbose' ] = true;  | 
                                                        |
| 279 | 279 | }  | 
                                                        
| 280 | 280 | |
| 281 | -        $response = $this->apiRequest('check', $data, 'GET') ; | 
                                                        |
| 281 | +        $response = $this->apiRequest('check', $data, 'GET'); | 
                                                        |
| 282 | 282 | |
| 283 | 283 | return json_decode($response, $returnArray);  | 
                                                        
| 284 | 284 | }  | 
                                                        
@@ -305,7 +305,7 @@ discard block  | 
                                                    ||
| 305 | 305 | public function clear(string $ip = null, bool $returnArray = false)  | 
                                                        
| 306 | 306 |      { | 
                                                        
| 307 | 307 | // ip must be set  | 
                                                        
| 308 | -        if (empty($ip)){ | 
                                                        |
| 308 | +        if (empty($ip)) { | 
                                                        |
| 309 | 309 |              throw new \InvalidArgumentException('ip argument must be set (null given)'); | 
                                                        
| 310 | 310 | }  | 
                                                        
| 311 | 311 | |
@@ -314,7 +314,7 @@ discard block  | 
                                                    ||
| 314 | 314 | 'ipAddress' => $ip,  | 
                                                        
| 315 | 315 | ];  | 
                                                        
| 316 | 316 | |
| 317 | -        $response = $this->apiRequest('clear-address', $data, "DELETE") ; | 
                                                        |
| 317 | +        $response = $this->apiRequest('clear-address', $data, "DELETE"); | 
                                                        |
| 318 | 318 | return json_decode($response, $returnArray);  | 
                                                        
| 319 | 319 | }  | 
                                                        
| 320 | 320 | |
@@ -333,7 +333,7 @@ discard block  | 
                                                    ||
| 333 | 333 | public function getBlacklist(int $limit = 10000, bool $plainText = false, bool $returnArray = false)  | 
                                                        
| 334 | 334 |      { | 
                                                        
| 335 | 335 | |
| 336 | -        if ($limit < 1){ | 
                                                        |
| 336 | +        if ($limit < 1) { | 
                                                        |
| 337 | 337 |              throw new \InvalidArgumentException('limit must be at least 1 (' . $limit . ' was given)'); | 
                                                        
| 338 | 338 | }  | 
                                                        
| 339 | 339 | |
@@ -345,13 +345,13 @@ discard block  | 
                                                    ||
| 345 | 345 | |
| 346 | 346 | // plaintext paremeter has no value and must be added only when true  | 
                                                        
| 347 | 347 | // (set plaintext=false won't work)  | 
                                                        
| 348 | -        if ($plainText){ | 
                                                        |
| 349 | - $data['plaintext'] = $plainText;  | 
                                                        |
| 348 | +        if ($plainText) { | 
                                                        |
| 349 | + $data[ 'plaintext' ] = $plainText;  | 
                                                        |
| 350 | 350 | }  | 
                                                        
| 351 | 351 | |
| 352 | 352 |          $response = $this->apiRequest('blacklist', $data, 'GET'); | 
                                                        
| 353 | 353 | |
| 354 | -        if ($plainText){ | 
                                                        |
| 354 | +        if ($plainText) { | 
                                                        |
| 355 | 355 | return $response;  | 
                                                        
| 356 | 356 | }  | 
                                                        
| 357 | 357 | |
@@ -382,21 +382,21 @@ discard block  | 
                                                    ||
| 382 | 382 |          foreach ($cats as $cat) { | 
                                                        
| 383 | 383 | |
| 384 | 384 | // get index on our array of categories  | 
                                                        
| 385 | - $catIndex = is_numeric($cat) ? $this->getCategoryIndex($cat, 1) : $this->getCategoryIndex($cat, 0);  | 
                                                        |
| 385 | + $catIndex = is_numeric($cat) ? $this->getCategoryIndex($cat, 1) : $this->getCategoryIndex($cat, 0);  | 
                                                        |
| 386 | 386 | |
| 387 | 387 | // check if found  | 
                                                        
| 388 | -            if ($catIndex === false ){ | 
                                                        |
| 389 | -                throw new \InvalidArgumentException('Invalid report category was given : ['. $cat .  ']'); | 
                                                        |
| 388 | +            if ($catIndex === false) { | 
                                                        |
| 389 | +                throw new \InvalidArgumentException('Invalid report category was given : [' . $cat . ']'); | 
                                                        |
| 390 | 390 | }  | 
                                                        
| 391 | 391 | |
| 392 | 392 | // get Id  | 
                                                        
| 393 | - $catId = $this->aipdbApiCategories[$catIndex][1];  | 
                                                        |
| 393 | + $catId = $this->aipdbApiCategories[ $catIndex ][ 1 ];  | 
                                                        |
| 394 | 394 | |
| 395 | 395 | // need another ?  | 
                                                        
| 396 | -            if ($needAnother !== false){ | 
                                                        |
| 396 | +            if ($needAnother !== false) { | 
                                                        |
| 397 | 397 | |
| 398 | 398 | // is a standalone cat ?  | 
                                                        
| 399 | -                if ($this->aipdbApiCategories[$catIndex][3] === false) { | 
                                                        |
| 399 | +                if ($this->aipdbApiCategories[ $catIndex ][ 3 ] === false) { | 
                                                        |
| 400 | 400 | $needAnother = true;  | 
                                                        
| 401 | 401 | |
| 402 | 402 |                  } else { | 
                                                        
@@ -407,10 +407,10 @@ discard block  | 
                                                    ||
| 407 | 407 | }  | 
                                                        
| 408 | 408 | |
| 409 | 409 | // set or add to cats list  | 
                                                        
| 410 | - $catsString = ($catsString === '') ? $catId : $catsString .','.$catId;  | 
                                                        |
| 410 | + $catsString = ($catsString === '') ? $catId : $catsString . ',' . $catId;  | 
                                                        |
| 411 | 411 | }  | 
                                                        
| 412 | 412 | |
| 413 | -        if ($needAnother !== false){ | 
                                                        |
| 413 | +        if ($needAnother !== false) { | 
                                                        |
| 414 | 414 |              throw new \InvalidArgumentException('Invalid report category paremeter given: some categories can\'t be used alone'); | 
                                                        
| 415 | 415 | }  | 
                                                        
| 416 | 416 | |
@@ -483,7 +483,7 @@ discard block  | 
                                                    ||
| 483 | 483 |          $message = str_replace('\\', '', $message); | 
                                                        
| 484 | 484 | |
| 485 | 485 | // Remove self ips  | 
                                                        
| 486 | -        foreach ($this->selfIps as $ip){ | 
                                                        |
| 486 | +        foreach ($this->selfIps as $ip) { | 
                                                        |
| 487 | 487 | $message = str_replace($ip, '*', $message);  | 
                                                        
| 488 | 488 | }  | 
                                                        
| 489 | 489 | |
@@ -510,7 +510,7 @@ discard block  | 
                                                    ||
| 510 | 510 | protected static function loadJsonFile(string $filePath, bool $throwError = true)  | 
                                                        
| 511 | 511 |      { | 
                                                        
| 512 | 512 | // check file exists  | 
                                                        
| 513 | -        if (!file_exists($filePath) || !is_file($filePath)){ | 
                                                        |
| 513 | +        if (!file_exists($filePath) || !is_file($filePath)) { | 
                                                        |
| 514 | 514 |             if ($throwError) { | 
                                                        
| 515 | 515 |                  throw new \Exception('Config file not found'); | 
                                                        
| 516 | 516 | }  | 
                                                        
@@ -522,7 +522,7 @@ discard block  | 
                                                    ||
| 522 | 522 | $json = json_decode(utf8_encode($content));  | 
                                                        
| 523 | 523 | |
| 524 | 524 | // check for errors  | 
                                                        
| 525 | -        if ($json == null && json_last_error() != JSON_ERROR_NONE){ | 
                                                        |
| 525 | +        if ($json == null && json_last_error() != JSON_ERROR_NONE) { | 
                                                        |
| 526 | 526 |              if ($throwError) { | 
                                                        
| 527 | 527 |                  throw new \LogicException(sprintf("Failed to parse config file Error: '%s'", json_last_error_msg())); | 
                                                        
| 528 | 528 | }  |