@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @access protected |
| 45 | 45 | * @var array |
| 46 | 46 | */ |
| 47 | - protected $selfIps = []; |
|
| 47 | + protected $selfIps = [ ]; |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Constructor |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param array $myIps The Ips/domain name you don't want to display in report messages |
| 55 | 55 | * |
| 56 | 56 | */ |
| 57 | - public function __construct(string $apiKey, array $myIps = []) |
|
| 57 | + public function __construct(string $apiKey, array $myIps = [ ]) |
|
| 58 | 58 | { |
| 59 | 59 | $this->aipdbApiKey = $apiKey; |
| 60 | 60 | $this->selfIps = $myIps; |
@@ -98,17 +98,17 @@ discard block |
||
| 98 | 98 | public function report(string $ip, string $categories, string $message): ApiResponse |
| 99 | 99 | { |
| 100 | 100 | // ip must be set |
| 101 | - if (empty($ip)){ |
|
| 101 | + if (empty($ip)) { |
|
| 102 | 102 | throw new \InvalidArgumentException('Ip was empty'); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // categories must be set |
| 106 | - if (empty($categories)){ |
|
| 106 | + if (empty($categories)) { |
|
| 107 | 107 | throw new \InvalidArgumentException('Categories list was empty'); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | // message must be set |
| 111 | - if (empty($message)){ |
|
| 111 | + if (empty($message)) { |
|
| 112 | 112 | throw new \InvalidArgumentException('Report message was empty'); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -164,16 +164,16 @@ discard block |
||
| 164 | 164 | public function bulkReport(string $filePath): ApiResponse |
| 165 | 165 | { |
| 166 | 166 | // check file exists |
| 167 | - if (!file_exists($filePath) || !is_file($filePath)){ |
|
| 167 | + if (!file_exists($filePath) || !is_file($filePath)) { |
|
| 168 | 168 | throw new \InvalidArgumentException('The file [' . $filePath . '] does not exist.'); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // check file is readable |
| 172 | - if (!is_readable($filePath)){ |
|
| 172 | + if (!is_readable($filePath)) { |
|
| 173 | 173 | throw new InvalidPermissionException('The file [' . $filePath . '] is not readable.'); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - return $this->apiRequest('bulk-report', [], 'POST', $filePath); |
|
| 176 | + return $this->apiRequest('bulk-report', [ ], 'POST', $filePath); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -197,11 +197,11 @@ discard block |
||
| 197 | 197 | public function clearAddress(string $ip): ApiResponse |
| 198 | 198 | { |
| 199 | 199 | // ip must be set |
| 200 | - if (empty($ip)){ |
|
| 200 | + if (empty($ip)) { |
|
| 201 | 201 | throw new \InvalidArgumentException('IP argument must be set.'); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - return $this->apiRequest('clear-address', ['ipAddress' => $ip ], "DELETE") ; |
|
| 204 | + return $this->apiRequest('clear-address', [ 'ipAddress' => $ip ], "DELETE"); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | public function check(string $ip, int $maxAgeInDays = 30, bool $verbose = false): ApiResponse |
| 220 | 220 | { |
| 221 | 221 | // max age must be less or equal to 365 |
| 222 | - if ( $maxAgeInDays > 365 || $maxAgeInDays < 1 ){ |
|
| 222 | + if ($maxAgeInDays > 365 || $maxAgeInDays < 1) { |
|
| 223 | 223 | throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365.'); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // ip must be set |
| 227 | - if (empty($ip)){ |
|
| 227 | + if (empty($ip)) { |
|
| 228 | 228 | throw new \InvalidArgumentException('ip argument must be set (empty value given)'); |
| 229 | 229 | } |
| 230 | 230 | |
@@ -235,11 +235,11 @@ discard block |
||
| 235 | 235 | ]; |
| 236 | 236 | |
| 237 | 237 | // option |
| 238 | - if ($verbose){ |
|
| 239 | - $data['verbose'] = true; |
|
| 238 | + if ($verbose) { |
|
| 239 | + $data[ 'verbose' ] = true; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - return $this->apiRequest('check', $data, 'GET') ; |
|
| 242 | + return $this->apiRequest('check', $data, 'GET'); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | public function checkBlock(string $network, int $maxAgeInDays = 30): ApiResponse |
| 289 | 289 | { |
| 290 | 290 | // max age must be between 1 and 365 |
| 291 | - if ($maxAgeInDays > 365 || $maxAgeInDays < 1){ |
|
| 291 | + if ($maxAgeInDays > 365 || $maxAgeInDays < 1) { |
|
| 292 | 292 | throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365 (' . $maxAgeInDays . ' was given)'); |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // ip must be set |
| 296 | - if (empty($network)){ |
|
| 296 | + if (empty($network)) { |
|
| 297 | 297 | throw new \InvalidArgumentException('network argument must be set (empty value given)'); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | public function blacklist(int $limit = 10000, bool $plainText = false, int $confidenceMinimum = 100): ApiResponse |
| 324 | 324 | { |
| 325 | - if ($limit < 1){ |
|
| 325 | + if ($limit < 1) { |
|
| 326 | 326 | throw new \InvalidArgumentException('limit must be at least 1 (' . $limit . ' was given)'); |
| 327 | 327 | } |
| 328 | 328 | |
@@ -334,8 +334,8 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | // plaintext paremeter has no value and must be added only when true |
| 336 | 336 | // (set plaintext=false won't work) |
| 337 | - if ($plainText){ |
|
| 338 | - $data['plaintext'] = $plainText; |
|
| 337 | + if ($plainText) { |
|
| 338 | + $data[ 'plaintext' ] = $plainText; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | return $this->apiRequest('blacklist', $data, 'GET'); |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | $ch = curl_init(); |
| 371 | 371 | |
| 372 | 372 | // for csv |
| 373 | - if (!empty($csvFilePath)){ |
|
| 374 | - $cfile = new \CurlFile($csvFilePath, 'text/csv', 'csv'); |
|
| 373 | + if (!empty($csvFilePath)) { |
|
| 374 | + $cfile = new \CurlFile($csvFilePath, 'text/csv', 'csv'); |
|
| 375 | 375 | //curl file itself return the realpath with prefix of @ |
| 376 | 376 | $data = array('csv' => $cfile); |
| 377 | 377 | } |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $message = str_replace('\\', '', $message); |
| 417 | 417 | |
| 418 | 418 | // Remove self ips |
| 419 | - foreach ($this->selfIps as $ip){ |
|
| 419 | + foreach ($this->selfIps as $ip) { |
|
| 420 | 420 | $message = str_replace($ip, '*', $message); |
| 421 | 421 | } |
| 422 | 422 | |
@@ -110,6 +110,6 @@ |
||
| 110 | 110 | */ |
| 111 | 111 | public function errors(): array |
| 112 | 112 | { |
| 113 | - return ($this->decodedResponse && $this->decodedResponse->errors) ? $this->decodedResponse->errors : []; |
|
| 113 | + return ($this->decodedResponse && $this->decodedResponse->errors) ? $this->decodedResponse->errors : [ ]; |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | \ No newline at end of file |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | public function report(string $ip, string $categories, string $message): ApiResponse |
| 65 | 65 | { |
| 66 | 66 | try { |
| 67 | - return parent::report($ip,$categories,$message); |
|
| 67 | + return parent::report($ip, $categories, $message); |
|
| 68 | 68 | } catch (\Exception $e) { |
| 69 | 69 | return $this->getErrorResponse($e->getMessage()); |
| 70 | 70 | } |