@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected static function inArguments(array $arguments, string $shortArg, string $longArg) |
93 | 93 | { |
94 | - return array_key_exists($shortArg, $arguments) || array_key_exists($longArg, $arguments); |
|
94 | + return array_key_exists($shortArg, $arguments) || array_key_exists($longArg, $arguments); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @access public |
101 | 101 | * @static |
102 | - * @param string $filePath The file's full path |
|
103 | - * @param bool $throwError Throw error on true or silent process. Default is true |
|
102 | + * @param string $filePath The file's full path |
|
103 | + * @param bool $throwError Throw error on true or silent process. Default is true |
|
104 | 104 | * |
105 | - * @return object|null |
|
105 | + * @return object|null |
|
106 | 106 | * @throws \Exception |
107 | 107 | * @throws \LogicException |
108 | 108 | */ |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | { |
111 | 111 | // check file exists |
112 | 112 | if (!file_exists($filePath) || !is_file($filePath)){ |
113 | - if ($throwError) { |
|
113 | + if ($throwError) { |
|
114 | 114 | throw new \Exception('Config file not found'); |
115 | - } |
|
116 | - return null; |
|
115 | + } |
|
116 | + return null; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // get and parse content |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | protected static function getScoreColor($score) |
57 | 57 | { |
58 | 58 | $score = intval($score); |
59 | - return $score > 50 ? 'lightred' : ($score > 0 ? 'yellow' : 'green') ; |
|
59 | + return $score > 50 ? 'lightred' : ($score > 0 ? 'yellow' : 'green'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -74,8 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | protected static function getArgumentValue(array $arguments, string $shortArg, string $longArg) |
76 | 76 | { |
77 | - return (array_key_exists($shortArg, $arguments) ? $arguments[$shortArg] : |
|
78 | - (array_key_exists($longArg, $arguments) ? $arguments[$longArg] : '')); |
|
77 | + return (array_key_exists($shortArg, $arguments) ? $arguments[$shortArg] : (array_key_exists($longArg, $arguments) ? $arguments[$longArg] : '')); |
|
79 | 78 | } |
80 | 79 | |
81 | 80 | /** |
@@ -109,7 +108,7 @@ discard block |
||
109 | 108 | protected static function loadJsonFile(string $filePath, bool $throwError = true) |
110 | 109 | { |
111 | 110 | // check file exists |
112 | - if (!file_exists($filePath) || !is_file($filePath)){ |
|
111 | + if (!file_exists($filePath) || !is_file($filePath)) { |
|
113 | 112 | if ($throwError) { |
114 | 113 | throw new \Exception('Config file not found'); |
115 | 114 | } |
@@ -105,38 +105,38 @@ |
||
105 | 105 | |
106 | 106 | Console::log(' ' . Console::text('SYNOPSIS:', 'white', 'underline')); |
107 | 107 | Console::log(' ' . Console::text(' abuseipdb -C ') . |
108 | - Console::text('IP', 'yellow') . |
|
109 | - Console::text(' [-d ') . |
|
110 | - Console::text('DAYS', 'yellow') . |
|
111 | - Console::text('] [-v] [-l ') . |
|
112 | - Console::text('LIMIT', 'yellow') . |
|
113 | - Console::text(']')); |
|
108 | + Console::text('IP', 'yellow') . |
|
109 | + Console::text(' [-d ') . |
|
110 | + Console::text('DAYS', 'yellow') . |
|
111 | + Console::text('] [-v] [-l ') . |
|
112 | + Console::text('LIMIT', 'yellow') . |
|
113 | + Console::text(']')); |
|
114 | 114 | |
115 | 115 | Console::log(' ' . Console::text(' abuseipdb -K ') . |
116 | - Console::text('NETWORK', 'yellow') . |
|
117 | - Console::text(' [-d ') . |
|
118 | - Console::text('DAYS', 'yellow') . |
|
119 | - Console::text(']')); |
|
116 | + Console::text('NETWORK', 'yellow') . |
|
117 | + Console::text(' [-d ') . |
|
118 | + Console::text('DAYS', 'yellow') . |
|
119 | + Console::text(']')); |
|
120 | 120 | |
121 | 121 | Console::log(' ' . Console::text(' abuseipdb -R ' . |
122 | - Console::text('IP', 'yellow') . ' -c ' . |
|
123 | - Console::text('CATEGORIES', 'yellow') . ' -m ' . |
|
124 | - Console::text('MESSAGE', 'yellow'))); |
|
122 | + Console::text('IP', 'yellow') . ' -c ' . |
|
123 | + Console::text('CATEGORIES', 'yellow') . ' -m ' . |
|
124 | + Console::text('MESSAGE', 'yellow'))); |
|
125 | 125 | |
126 | 126 | Console::log(' ' . Console::text(' abuseipdb -V ' . |
127 | - Console::text('FILE', 'yellow'))); |
|
127 | + Console::text('FILE', 'yellow'))); |
|
128 | 128 | |
129 | 129 | Console::log(' ' . Console::text(' abuseipdb -E ' . |
130 | - Console::text('IP', 'yellow'))); |
|
130 | + Console::text('IP', 'yellow'))); |
|
131 | 131 | |
132 | 132 | Console::log(' ' . Console::text(' abuseipdb -B ') . |
133 | - Console::text('[-l ') . |
|
134 | - Console::text('LIMIT', 'yellow') . |
|
135 | - Console::text('] [-s ') . |
|
136 | - Console::text('SCORE', 'yellow') . |
|
137 | - Console::text('] [-p ') . |
|
138 | - Console::text('', 'yellow') . |
|
139 | - Console::text(']')); |
|
133 | + Console::text('[-l ') . |
|
134 | + Console::text('LIMIT', 'yellow') . |
|
135 | + Console::text('] [-s ') . |
|
136 | + Console::text('SCORE', 'yellow') . |
|
137 | + Console::text('] [-p ') . |
|
138 | + Console::text('', 'yellow') . |
|
139 | + Console::text(']')); |
|
140 | 140 | |
141 | 141 | Console::log(' ' . Console::text(' abuseipdb -L | -G | -h | --version')); |
142 | 142 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | // required at least one valid argument |
50 | 50 | self::$keyPath = $keyPath; |
51 | - self::validate( !empty($arguments), 'No valid arguments given. Run abuseipdb --help to get help.'); |
|
51 | + self::validate(!empty($arguments), 'No valid arguments given. Run abuseipdb --help to get help.'); |
|
52 | 52 | if (!self::parseCommand($arguments, $keyPath)) { |
53 | 53 | self::error('Invalid arguments. Run abuseipdb --help to get help.'); |
54 | 54 | self::printFooter(); |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | { |
70 | 70 | self::printTitle(Console::text(' ► Register API key ', 'darkgray')); |
71 | 71 | |
72 | - $key = self::getArgumentValue($arguments,'S', 'save-key'); |
|
72 | + $key = self::getArgumentValue($arguments, 'S', 'save-key'); |
|
73 | 73 | |
74 | - if (empty($key)){ |
|
74 | + if (empty($key)) { |
|
75 | 75 | self::error('Null or invalid key argument.'); |
76 | 76 | self::printFooter(); |
77 | 77 | Program::exit(1); |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | |
80 | 80 | $data = json_encode(['api_key' => $key]); |
81 | 81 | |
82 | - if (file_put_contents(self::$keyPath, $data, LOCK_EX) === false){ |
|
82 | + if (file_put_contents(self::$keyPath, $data, LOCK_EX) === false) { |
|
83 | 83 | self::error('An error occured during writing config file. Make sure to give the appropriate permissions do the config directory.'); |
84 | 84 | self::printFooter(); |
85 | 85 | Program::exit(1); |
86 | 86 | } |
87 | - Console::log(Console::text(' ✓ ', 'green') . Console::text('Your config key file has been successfully created.', 'white')); |
|
87 | + Console::log(Console::text(' ✓ ', 'green').Console::text('Your config key file has been successfully created.', 'white')); |
|
88 | 88 | Console::log(); |
89 | 89 | self::printFooter(); |
90 | 90 | Program::exit(); |
@@ -102,45 +102,45 @@ discard block |
||
102 | 102 | { |
103 | 103 | self::printBanner(); |
104 | 104 | |
105 | - Console::log(' ' . Console::text('SYNOPSIS:', 'white', 'underline')); |
|
106 | - Console::log(' ' . Console::text(' abuseipdb -C ') . |
|
107 | - Console::text('IP', 'yellow') . |
|
108 | - Console::text(' [-d ') . |
|
109 | - Console::text('DAYS', 'yellow') . |
|
110 | - Console::text('] [-v] [-l ') . |
|
111 | - Console::text('LIMIT', 'yellow') . |
|
105 | + Console::log(' '.Console::text('SYNOPSIS:', 'white', 'underline')); |
|
106 | + Console::log(' '.Console::text(' abuseipdb -C '). |
|
107 | + Console::text('IP', 'yellow'). |
|
108 | + Console::text(' [-d '). |
|
109 | + Console::text('DAYS', 'yellow'). |
|
110 | + Console::text('] [-v] [-l '). |
|
111 | + Console::text('LIMIT', 'yellow'). |
|
112 | 112 | Console::text(']')); |
113 | 113 | |
114 | - Console::log(' ' . Console::text(' abuseipdb -K ') . |
|
115 | - Console::text('NETWORK', 'yellow') . |
|
116 | - Console::text(' [-d ') . |
|
117 | - Console::text('DAYS', 'yellow') . |
|
114 | + Console::log(' '.Console::text(' abuseipdb -K '). |
|
115 | + Console::text('NETWORK', 'yellow'). |
|
116 | + Console::text(' [-d '). |
|
117 | + Console::text('DAYS', 'yellow'). |
|
118 | 118 | Console::text(']')); |
119 | 119 | |
120 | - Console::log(' ' . Console::text(' abuseipdb -R ' . |
|
121 | - Console::text('IP', 'yellow') . ' -c ' . |
|
122 | - Console::text('CATEGORIES', 'yellow') . ' -m ' . |
|
120 | + Console::log(' '.Console::text(' abuseipdb -R '. |
|
121 | + Console::text('IP', 'yellow').' -c '. |
|
122 | + Console::text('CATEGORIES', 'yellow').' -m '. |
|
123 | 123 | Console::text('MESSAGE', 'yellow'))); |
124 | 124 | |
125 | - Console::log(' ' . Console::text(' abuseipdb -V ' . |
|
125 | + Console::log(' '.Console::text(' abuseipdb -V '. |
|
126 | 126 | Console::text('FILE', 'yellow'))); |
127 | 127 | |
128 | - Console::log(' ' . Console::text(' abuseipdb -E ' . |
|
128 | + Console::log(' '.Console::text(' abuseipdb -E '. |
|
129 | 129 | Console::text('IP', 'yellow'))); |
130 | 130 | |
131 | - Console::log(' ' . Console::text(' abuseipdb -B ') . |
|
132 | - Console::text('[-l ') . |
|
133 | - Console::text('LIMIT', 'yellow') . |
|
134 | - Console::text('] [-s ') . |
|
135 | - Console::text('SCORE', 'yellow') . |
|
136 | - Console::text('] [-p ') . |
|
137 | - Console::text('', 'yellow') . |
|
131 | + Console::log(' '.Console::text(' abuseipdb -B '). |
|
132 | + Console::text('[-l '). |
|
133 | + Console::text('LIMIT', 'yellow'). |
|
134 | + Console::text('] [-s '). |
|
135 | + Console::text('SCORE', 'yellow'). |
|
136 | + Console::text('] [-p '). |
|
137 | + Console::text('', 'yellow'). |
|
138 | 138 | Console::text(']')); |
139 | 139 | |
140 | - Console::log(' ' . Console::text(' abuseipdb -L | -G | -h | --version')); |
|
140 | + Console::log(' '.Console::text(' abuseipdb -L | -G | -h | --version')); |
|
141 | 141 | |
142 | 142 | Console::log(); |
143 | - Console::log(' ' . Console::text('OPTIONS:', 'white', 'underline')); |
|
143 | + Console::log(' '.Console::text('OPTIONS:', 'white', 'underline')); |
|
144 | 144 | Console::log(); |
145 | 145 | Console::log(Console::text(' -h, --help', 'white')); |
146 | 146 | Console::log(' Prints the current help. If given, all next arguments are ignored.', 'lightgray'); |
@@ -151,39 +151,39 @@ discard block |
||
151 | 151 | Console::log(Console::text(' -L, --list', 'white')); |
152 | 152 | Console::log(' Prints the list report categories. If given, all next arguments are ignored.', 'lightgray'); |
153 | 153 | Console::log(); |
154 | - Console::log(Console::text(' -C, --check ', 'white') . Console::text('ip', 'yellow', 'underline')); |
|
154 | + Console::log(Console::text(' -C, --check ', 'white').Console::text('ip', 'yellow', 'underline')); |
|
155 | 155 | Console::log(' Performs a check request for the given IP address. A valid IPv4 or IPv6 address is required.', 'lightgray'); |
156 | 156 | Console::log(); |
157 | - Console::log(Console::text(' -K, --check-block ', 'white') . Console::text('network', 'yellow', 'underline')); |
|
157 | + Console::log(Console::text(' -K, --check-block ', 'white').Console::text('network', 'yellow', 'underline')); |
|
158 | 158 | Console::log(' Performs a check-block request for the given network. A valid subnet (v4 or v6) denoted with ', 'lightgray'); |
159 | 159 | Console::log(' CIDR notation is required.', 'lightgray'); |
160 | 160 | Console::log(); |
161 | - Console::log(Console::text(' -d, --days ', 'white') . Console::text('days', 'yellow', 'underline')); |
|
161 | + Console::log(Console::text(' -d, --days ', 'white').Console::text('days', 'yellow', 'underline')); |
|
162 | 162 | Console::log(' For a check or check-block request, defines the maxAgeDays. Min is 1, max is 365, default is 30.', 'lightgray'); |
163 | 163 | Console::log(); |
164 | - Console::log(Console::text(' -R, --report ', 'white') . Console::text('ip', 'yellow', 'underline')); |
|
164 | + Console::log(Console::text(' -R, --report ', 'white').Console::text('ip', 'yellow', 'underline')); |
|
165 | 165 | Console::log(' Performs a report request for the given IP address. A valid IPv4 or IPv6 address is required.', 'lightgray'); |
166 | 166 | Console::log(); |
167 | - Console::log(Console::text(' -V, --bulk-report ', 'white') . Console::text('path', 'yellow', 'underline')); |
|
167 | + Console::log(Console::text(' -V, --bulk-report ', 'white').Console::text('path', 'yellow', 'underline')); |
|
168 | 168 | Console::log(' Performs a bulk-report request sending a csv file. A valid file name or full path is required.', 'lightgray'); |
169 | 169 | Console::log(); |
170 | 170 | Console::log(Console::text(' -E, --clear ', 'white')); |
171 | 171 | Console::log(' Remove own reports for the given IP address. A valid IPv4 or IPv6 address is required.', 'lightgray'); |
172 | 172 | Console::log(); |
173 | - Console::log(Console::text(' -c, --categories ', 'white') . Console::text('categories', 'yellow', 'underline')); |
|
173 | + Console::log(Console::text(' -c, --categories ', 'white').Console::text('categories', 'yellow', 'underline')); |
|
174 | 174 | Console::log(' For a report request, defines the report category(ies). Categories must be separate by a comma.', 'lightgray'); |
175 | 175 | Console::log(' Some categories cannot be used alone. A category can be represented by its shortname or by its', 'lightgray'); |
176 | - Console::log(Console::text(' id. Use ','lightgray') . Console::text('abuseipdb -L', 'white') . Console::text(' to print the categories list.','lightgray')); |
|
176 | + Console::log(Console::text(' id. Use ', 'lightgray').Console::text('abuseipdb -L', 'white').Console::text(' to print the categories list.', 'lightgray')); |
|
177 | 177 | Console::log(); |
178 | - Console::log(Console::text(' -m, --message ', 'white') . Console::text('message', 'yellow', 'underline')); |
|
178 | + Console::log(Console::text(' -m, --message ', 'white').Console::text('message', 'yellow', 'underline')); |
|
179 | 179 | Console::log(' For a report request, defines the message to send with report. Message is required for all', 'lightgray'); |
180 | 180 | Console::log(' report requests.', 'lightgray'); |
181 | 181 | Console::log(); |
182 | 182 | Console::log(Console::text(' -B, --blacklist ', 'white')); |
183 | 183 | Console::log(' Performs a blacklist request. Default limit is 1000. This limit can ne changed with the', 'lightgray'); |
184 | - Console::log(' ' . Console::text('--limit', 'white') . Console::text(' parameter. ', 'lightgray')); |
|
184 | + Console::log(' '.Console::text('--limit', 'white').Console::text(' parameter. ', 'lightgray')); |
|
185 | 185 | Console::log(); |
186 | - Console::log(Console::text(' -l, --limit ', 'white') . Console::text('limit', 'yellow', 'underline')); |
|
186 | + Console::log(Console::text(' -l, --limit ', 'white').Console::text('limit', 'yellow', 'underline')); |
|
187 | 187 | Console::log(' For a blacklist request, defines the limit.', 'lightgray'); |
188 | 188 | Console::log(' For a check request with verbose flag, sets the max number of last reports displayed. Default is 10', 'lightgray'); |
189 | 189 | Console::log(' For a check-block request, sets the max number of IPs displayed. Default is 0 (no limit).', 'lightgray'); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | Console::log(Console::text(' -v, --verbose ', 'white')); |
199 | 199 | Console::log(' For a check request, display additional fields like the x last reports. This increases ', 'lightgray'); |
200 | 200 | Console::log(Console::text(' request time and response size. Max number of last reports displayed can be changed with the ', 'lightgray')); |
201 | - Console::log(' ' . Console::text('--limit', 'white') . Console::text(' parameter. ', 'lightgray')); |
|
201 | + Console::log(' '.Console::text('--limit', 'white').Console::text(' parameter. ', 'lightgray')); |
|
202 | 202 | Console::log(); |
203 | 203 | Console::log(Console::text(' --version', 'white')); |
204 | 204 | Console::log(' Prints the current version. If given, all next arguments are ignored.', 'lightgray'); |
@@ -219,11 +219,11 @@ discard block |
||
219 | 219 | |
220 | 220 | self::printTitle(Console::text(' ► Current configuration ', 'darkgray')); |
221 | 221 | |
222 | - Console::log(Console::text(' api_key:[', 'white') . Console::text($conf['apiKey'], 'green') . Console::text(']', 'white')); |
|
222 | + Console::log(Console::text(' api_key:[', 'white').Console::text($conf['apiKey'], 'green').Console::text(']', 'white')); |
|
223 | 223 | Console::log(Console::text(' self_ips:', 'white')); |
224 | 224 | |
225 | 225 | foreach ($conf['selfIps'] as $ip) { |
226 | - Console::log(Console::text(' [', 'white') . Console::text($ip, 'green') . Console::text(']', 'white')); |
|
226 | + Console::log(Console::text(' [', 'white').Console::text($ip, 'green').Console::text(']', 'white')); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | Console::log(); |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | |
245 | 245 | $categories = ApiHandler::getCategories(); |
246 | 246 | $rowHeaders = [ |
247 | - Console::text('ShortName', 'darkgray') => 15, |
|
248 | - Console::text('Id', 'darkgray') => 2, |
|
249 | - Console::text('Full name', 'darkgray') => 18, |
|
250 | - Console::text('Can be alone?', 'darkgray') => 15 |
|
247 | + Console::text('ShortName', 'darkgray') => 15, |
|
248 | + Console::text('Id', 'darkgray') => 2, |
|
249 | + Console::text('Full name', 'darkgray') => 18, |
|
250 | + Console::text('Can be alone?', 'darkgray') => 15 |
|
251 | 251 | ]; |
252 | 252 | Console::$verticalSeparator = ' '; |
253 | 253 | Console::$verticalInnerSeparator = ' '; |
@@ -257,17 +257,16 @@ discard block |
||
257 | 257 | |
258 | 258 | foreach ($categories as $cat) { |
259 | 259 | $id = Console::text($cat[1], 'white'); |
260 | - $standalone = $cat[3] ? Console::text('✓', 'green') . Console::text(' true ', 'lightgray') : |
|
261 | - Console::text('✗', 'red') . Console::text(' false', 'darkgray'); |
|
262 | - $shortName = Console::text($cat[0], 'white'); |
|
263 | - $fullName = Console::text($cat[2], 'lightgray'); |
|
260 | + $standalone = $cat[3] ? Console::text('✓', 'green').Console::text(' true ', 'lightgray') : Console::text('✗', 'red').Console::text(' false', 'darkgray'); |
|
261 | + $shortName = Console::text($cat[0], 'white'); |
|
262 | + $fullName = Console::text($cat[2], 'lightgray'); |
|
264 | 263 | |
265 | 264 | Console::log( |
266 | 265 | Console::TableRowStart(). |
267 | - Console::TableRowCell( $shortName , 15). |
|
268 | - Console::TableRowCell( $id , 2, Console::ALIGN_CENTER). |
|
269 | - Console::TableRowCell( $fullName , 18). |
|
270 | - Console::TableRowCell( $standalone , 15, Console::ALIGN_CENTER) |
|
266 | + Console::TableRowCell($shortName, 15). |
|
267 | + Console::TableRowCell($id, 2, Console::ALIGN_CENTER). |
|
268 | + Console::TableRowCell($fullName, 18). |
|
269 | + Console::TableRowCell($standalone, 15, Console::ALIGN_CENTER) |
|
271 | 270 | ); |
272 | 271 | } |
273 | 272 | //Console::log(Console::tableRowSeparator($rowHeaders), 'darkgray'); |
@@ -286,11 +285,11 @@ discard block |
||
286 | 285 | */ |
287 | 286 | protected static function reportIP(array $arguments) |
288 | 287 | { |
289 | - $ip = self::getArgumentValue($arguments,'R', 'report'); |
|
290 | - $cats = self::getArgumentValue($arguments,'c', 'categories'); |
|
291 | - $message = self::getArgumentValue($arguments,'m', 'message'); |
|
288 | + $ip = self::getArgumentValue($arguments, 'R', 'report'); |
|
289 | + $cats = self::getArgumentValue($arguments, 'c', 'categories'); |
|
290 | + $message = self::getArgumentValue($arguments, 'm', 'message'); |
|
292 | 291 | |
293 | - self::printTitle(Console::text(' ► Report IP: ', 'darkgray') . Console::text(escapeshellcmd($ip), 'white')); |
|
292 | + self::printTitle(Console::text(' ► Report IP: ', 'darkgray').Console::text(escapeshellcmd($ip), 'white')); |
|
294 | 293 | self::printTempMessage(); |
295 | 294 | |
296 | 295 | // Peforms request |
@@ -301,7 +300,7 @@ discard block |
||
301 | 300 | self::clearTempMessage(); |
302 | 301 | |
303 | 302 | // check for errors / empty response |
304 | - if (self::hasErrors($report)){ |
|
303 | + if (self::hasErrors($report)) { |
|
305 | 304 | self::printFooter(); |
306 | 305 | Program::exit(1); |
307 | 306 | } |
@@ -310,23 +309,23 @@ discard block |
||
310 | 309 | $score = empty($report->data->abuseConfidenceScore) ? 0 : $report->data->abuseConfidenceScore; |
311 | 310 | $scoreColor = self::getScoreColor($score); |
312 | 311 | |
313 | - switch (self::$outputFormat){ |
|
312 | + switch (self::$outputFormat) { |
|
314 | 313 | case self::OUTPUT_JSON: |
315 | 314 | echo json_encode($report, JSON_PRETTY_PRINT); |
316 | 315 | break; |
317 | 316 | |
318 | 317 | case self::OUTPUT_DEFAULT: |
319 | 318 | Console::log( |
320 | - Console::text(' ✓', 'green') . Console::text(' IP: [', 'white') . |
|
321 | - Console::text($ip, $scoreColor) . Console::text('] successfully reported', 'white') |
|
319 | + Console::text(' ✓', 'green').Console::text(' IP: [', 'white'). |
|
320 | + Console::text($ip, $scoreColor).Console::text('] successfully reported', 'white') |
|
322 | 321 | ); |
323 | - Console::log(Console::text(' Confidence score: ', 'white') . self::getScoreBadge($score)); |
|
322 | + Console::log(Console::text(' Confidence score: ', 'white').self::getScoreBadge($score)); |
|
324 | 323 | Console::log(); |
325 | 324 | self::printFooter($time); |
326 | 325 | break; |
327 | 326 | |
328 | 327 | case self::OUTPUT_PLAINTEXT: |
329 | - echo $score . PHP_EOL; |
|
328 | + echo $score.PHP_EOL; |
|
330 | 329 | break; |
331 | 330 | |
332 | 331 | } |
@@ -343,26 +342,26 @@ discard block |
||
343 | 342 | */ |
344 | 343 | protected static function bulkReport(array $arguments) |
345 | 344 | { |
346 | - $fileName = self::getArgumentValue($arguments,'V', 'bulk-report'); |
|
345 | + $fileName = self::getArgumentValue($arguments, 'V', 'bulk-report'); |
|
347 | 346 | |
348 | - self::printTitle(Console::text(' ► Bulk report for file: ', 'darkgray') . Console::text(escapeshellcmd($fileName), 'white')); |
|
347 | + self::printTitle(Console::text(' ► Bulk report for file: ', 'darkgray').Console::text(escapeshellcmd($fileName), 'white')); |
|
349 | 348 | self::printTempMessage(); |
350 | 349 | |
351 | 350 | // Peforms request |
352 | 351 | $timeStart = microtime(true); |
353 | 352 | $response = self::$api->bulkReport($fileName)->getObject(); |
354 | 353 | $timeEnd = microtime(true); |
355 | - $time = $timeEnd - $timeStart; // request time |
|
354 | + $time = $timeEnd - $timeStart; // request time |
|
356 | 355 | self::clearTempMessage(); |
357 | 356 | |
358 | 357 | // check for errors / empty response |
359 | - if (self::hasErrors($response)){ |
|
358 | + if (self::hasErrors($response)) { |
|
360 | 359 | self::printFooter(); |
361 | 360 | Program::exit(1); |
362 | 361 | } |
363 | 362 | |
364 | 363 | // ✓ Done |
365 | - switch (self::$outputFormat){ |
|
364 | + switch (self::$outputFormat) { |
|
366 | 365 | case self::OUTPUT_JSON: |
367 | 366 | echo json_encode($response, JSON_PRETTY_PRINT); |
368 | 367 | break; |
@@ -377,7 +376,7 @@ discard block |
||
377 | 376 | |
378 | 377 | case self::OUTPUT_PLAINTEXT: |
379 | 378 | $nbSavedReports = isset($response->data->savedReports) ? $response->data->savedReports : 0; |
380 | - echo $nbSavedReports . PHP_EOL; |
|
379 | + echo $nbSavedReports.PHP_EOL; |
|
381 | 380 | break; |
382 | 381 | |
383 | 382 | } |
@@ -394,8 +393,8 @@ discard block |
||
394 | 393 | */ |
395 | 394 | protected static function clearIP(array $arguments) |
396 | 395 | { |
397 | - $ip = self::getArgumentValue($arguments,'E', 'clear'); |
|
398 | - self::printTitle(Console::text(' ► Clear reports for IP: ', 'darkgray') . Console::text(escapeshellcmd($ip), 'white')); |
|
396 | + $ip = self::getArgumentValue($arguments, 'E', 'clear'); |
|
397 | + self::printTitle(Console::text(' ► Clear reports for IP: ', 'darkgray').Console::text(escapeshellcmd($ip), 'white')); |
|
399 | 398 | |
400 | 399 | // Peforms request |
401 | 400 | self::printTempMessage(); |
@@ -406,22 +405,22 @@ discard block |
||
406 | 405 | self::clearTempMessage(); |
407 | 406 | |
408 | 407 | // check for errors / empty response |
409 | - if (self::hasErrors($response)){ |
|
408 | + if (self::hasErrors($response)) { |
|
410 | 409 | self::printFooter($time); |
411 | 410 | Program::exit(1); |
412 | 411 | } |
413 | 412 | |
414 | 413 | // ✓ Done: print deleted report number |
415 | - switch (self::$outputFormat){ |
|
414 | + switch (self::$outputFormat) { |
|
416 | 415 | case self::OUTPUT_JSON: |
417 | 416 | echo json_encode($response, JSON_PRETTY_PRINT); |
418 | 417 | break; |
419 | 418 | |
420 | 419 | case self::OUTPUT_DEFAULT: |
421 | 420 | Console::log( |
422 | - Console::text(' ✓', 'green') . |
|
423 | - Console::text(' Successfull clear request for IP: [', 'white') . |
|
424 | - Console::text($ip, 'lightyellow') . |
|
421 | + Console::text(' ✓', 'green'). |
|
422 | + Console::text(' Successfull clear request for IP: [', 'white'). |
|
423 | + Console::text($ip, 'lightyellow'). |
|
425 | 424 | Console::text(']', 'white') |
426 | 425 | ); |
427 | 426 | self::printResult(' Deleted reports: ', $response->data->numReportsDeleted ?? 0, 'lightyellow'); |
@@ -430,7 +429,7 @@ discard block |
||
430 | 429 | break; |
431 | 430 | |
432 | 431 | case self::OUTPUT_PLAINTEXT: |
433 | - echo ($response->data->numReportsDeleted ?? 0) . PHP_EOL; |
|
432 | + echo ($response->data->numReportsDeleted ?? 0).PHP_EOL; |
|
434 | 433 | break; |
435 | 434 | |
436 | 435 | } |
@@ -450,8 +449,8 @@ discard block |
||
450 | 449 | self::printTitle(Console::text(' ► Get Blacklist ', 'darkgray')); |
451 | 450 | |
452 | 451 | $plainText = self::$outputFormat === self::OUTPUT_PLAINTEXT; |
453 | - $limit = self::getNumericParameter($arguments,'l', 'limit', 1000); |
|
454 | - $scoreMin = self::getNumericParameter($arguments,'s', 'score', 100); |
|
452 | + $limit = self::getNumericParameter($arguments, 'l', 'limit', 1000); |
|
453 | + $scoreMin = self::getNumericParameter($arguments, 's', 'score', 100); |
|
455 | 454 | |
456 | 455 | self::printTempMessage(); |
457 | 456 | |
@@ -465,13 +464,13 @@ discard block |
||
465 | 464 | |
466 | 465 | // response could be json on error, while plaintext flag is set |
467 | 466 | $decodedResponse = $response->getObject(); |
468 | - if (self::hasErrors($decodedResponse, false)){ |
|
467 | + if (self::hasErrors($decodedResponse, false)) { |
|
469 | 468 | self::printFooter($time); |
470 | 469 | Program::exit(1); |
471 | 470 | } |
472 | 471 | |
473 | 472 | // ✓ Done: print deleted report number |
474 | - switch (self::$outputFormat){ |
|
473 | + switch (self::$outputFormat) { |
|
475 | 474 | case self::OUTPUT_JSON: |
476 | 475 | echo json_encode($response, JSON_PRETTY_PRINT); |
477 | 476 | break; |
@@ -480,7 +479,7 @@ discard block |
||
480 | 479 | // print list |
481 | 480 | self::printResult(' List generated at: ', self::getDate($decodedResponse->meta->generatedAt), 'lightyellow', ''); |
482 | 481 | Console::log(); |
483 | - foreach ($decodedResponse->data as $report){ |
|
482 | + foreach ($decodedResponse->data as $report) { |
|
484 | 483 | $score = empty($report->abuseConfidenceScore) ? 0 : $report->abuseConfidenceScore; |
485 | 484 | $defaultColor = self::getScoreColor($score); |
486 | 485 | |
@@ -515,12 +514,12 @@ discard block |
||
515 | 514 | */ |
516 | 515 | protected static function checkBlock(array $arguments) |
517 | 516 | { |
518 | - $network = self::getArgumentValue($arguments,'K', 'check-block'); |
|
517 | + $network = self::getArgumentValue($arguments, 'K', 'check-block'); |
|
519 | 518 | |
520 | - self::printTitle(Console::text(' ► Check network: ', 'darkgray') . Console::text(escapeshellcmd($network), 'white') . Console::text('', 'darkgray')); |
|
519 | + self::printTitle(Console::text(' ► Check network: ', 'darkgray').Console::text(escapeshellcmd($network), 'white').Console::text('', 'darkgray')); |
|
521 | 520 | |
522 | 521 | $maxAge = self::getNumericParameter($arguments, 'd', 'days', 30); |
523 | - $limit = self::getNumericParameter($arguments,'l', 'limit', 0); // 0 mean no limit |
|
522 | + $limit = self::getNumericParameter($arguments, 'l', 'limit', 0); // 0 mean no limit |
|
524 | 523 | |
525 | 524 | self::printTempMessage(); |
526 | 525 | |
@@ -531,19 +530,19 @@ discard block |
||
531 | 530 | self::clearTempMessage(); |
532 | 531 | |
533 | 532 | // check for errors / empty response |
534 | - if (self::hasErrors($check)){ |
|
533 | + if (self::hasErrors($check)) { |
|
535 | 534 | self::printFooter($time); |
536 | 535 | Program::exit(1); |
537 | 536 | } |
538 | 537 | |
539 | - switch (self::$outputFormat){ |
|
538 | + switch (self::$outputFormat) { |
|
540 | 539 | case self::OUTPUT_JSON: |
541 | 540 | echo json_encode($check, JSON_PRETTY_PRINT); |
542 | 541 | break; |
543 | 542 | |
544 | 543 | case self::OUTPUT_DEFAULT: |
545 | 544 | self::printCheckBlockDetail($check); |
546 | - self::printCheckBlockReportedIP($check,$maxAge,$limit); |
|
545 | + self::printCheckBlockReportedIP($check, $maxAge, $limit); |
|
547 | 546 | Console::log(); |
548 | 547 | self::printFooter($time); |
549 | 548 | break; |
@@ -552,8 +551,8 @@ discard block |
||
552 | 551 | $nbReports = isset($check->data->reportedAddress) ? count($check->data->reportedAddress) : 0; |
553 | 552 | if ($nbReports > 0) { |
554 | 553 | $numberDiplayedReports = 0; |
555 | - foreach ($check->data->reportedAddress as $report){ |
|
556 | - echo ($report->ipAddress) . ' ' . $report->abuseConfidenceScore . PHP_EOL; |
|
554 | + foreach ($check->data->reportedAddress as $report) { |
|
555 | + echo ($report->ipAddress).' '.$report->abuseConfidenceScore.PHP_EOL; |
|
557 | 556 | |
558 | 557 | // counter |
559 | 558 | $numberDiplayedReports++; |
@@ -577,14 +576,14 @@ discard block |
||
577 | 576 | */ |
578 | 577 | protected static function checkIP(array $arguments) |
579 | 578 | { |
580 | - $ip = self::getArgumentValue($arguments,'C', 'check'); |
|
579 | + $ip = self::getArgumentValue($arguments, 'C', 'check'); |
|
581 | 580 | |
582 | - self::printTitle(Console::text(' ► Check IP: ', 'darkgray') . Console::text(escapeshellcmd($ip), 'white') . Console::text('', 'darkgray')); |
|
581 | + self::printTitle(Console::text(' ► Check IP: ', 'darkgray').Console::text(escapeshellcmd($ip), 'white').Console::text('', 'darkgray')); |
|
583 | 582 | |
584 | - $verbose = self::inArguments($arguments,'v', 'verbose'); |
|
583 | + $verbose = self::inArguments($arguments, 'v', 'verbose'); |
|
585 | 584 | $maxAge = self::getNumericParameter($arguments, 'd', 'days', 30); |
586 | - $maxReportsNumber = self::getNumericParameter($arguments,'l', 'limit', 10); |
|
587 | - $ip = self::getArgumentValue($arguments,'C', 'check'); |
|
585 | + $maxReportsNumber = self::getNumericParameter($arguments, 'l', 'limit', 10); |
|
586 | + $ip = self::getArgumentValue($arguments, 'C', 'check'); |
|
588 | 587 | |
589 | 588 | self::printTempMessage(); |
590 | 589 | $timeStart = microtime(true); |
@@ -594,15 +593,15 @@ discard block |
||
594 | 593 | self::clearTempMessage(); |
595 | 594 | |
596 | 595 | // check for errors / empty response |
597 | - if (self::hasErrors($check)){ |
|
596 | + if (self::hasErrors($check)) { |
|
598 | 597 | self::printFooter($time); |
599 | 598 | Program::exit(1); |
600 | 599 | } |
601 | 600 | |
602 | 601 | // score and data color (depending of abuseConfidenceScore) |
603 | - $score = empty($check->data->abuseConfidenceScore) ? 0 : $check->data->abuseConfidenceScore; |
|
602 | + $score = empty($check->data->abuseConfidenceScore) ? 0 : $check->data->abuseConfidenceScore; |
|
604 | 603 | |
605 | - switch (self::$outputFormat){ |
|
604 | + switch (self::$outputFormat) { |
|
606 | 605 | case self::OUTPUT_JSON: |
607 | 606 | echo json_encode($check, JSON_PRETTY_PRINT); |
608 | 607 | break; |
@@ -612,7 +611,7 @@ discard block |
||
612 | 611 | self::printCheckScore($check); |
613 | 612 | self::printCheckDetail($check, $defaultColor); |
614 | 613 | self::printCheckReports($check, $maxAge, $defaultColor); |
615 | - if ($verbose){ |
|
614 | + if ($verbose) { |
|
616 | 615 | self::printCheckLastReports($check, $maxReportsNumber); |
617 | 616 | } |
618 | 617 | Console::log(); |
@@ -620,7 +619,7 @@ discard block |
||
620 | 619 | break; |
621 | 620 | |
622 | 621 | case self::OUTPUT_PLAINTEXT: |
623 | - echo ($check->data->abuseConfidenceScore ?? 0) . PHP_EOL; |
|
622 | + echo ($check->data->abuseConfidenceScore ?? 0).PHP_EOL; |
|
624 | 623 | break; |
625 | 624 | |
626 | 625 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @var string |
40 | 40 | */ |
41 | - const LONG_ARGUMENTS = ['output:','save-key:', 'config', 'list', 'blacklist', 'check:', 'check-block:', 'days:', 'report:', 'categories:', 'message:', 'limit:', 'clear:','bulk-report:', 'help', 'verbose', 'score:','version']; |
|
41 | + const LONG_ARGUMENTS = ['output:', 'save-key:', 'config', 'list', 'blacklist', 'check:', 'check-block:', 'days:', 'report:', 'categories:', 'message:', 'limit:', 'clear:', 'bulk-report:', 'help', 'verbose', 'score:', 'version']; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @var string |
@@ -53,29 +53,29 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @var string |
55 | 55 | */ |
56 | - protected static $keyPath = __DIR__ .'/../config/key.json'; |
|
56 | + protected static $keyPath = __DIR__.'/../config/key.json'; |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @var array |
60 | 60 | */ |
61 | 61 | protected static $basicCommands = [ |
62 | - ['h', 'help', 'printHelp'], |
|
63 | - ['version', 'version', 'printVersion'], // no short arg |
|
64 | - ['S', 'save-key', 'registerApiKey'], |
|
62 | + ['h', 'help', 'printHelp'], |
|
63 | + ['version', 'version', 'printVersion'], // no short arg |
|
64 | + ['S', 'save-key', 'registerApiKey'], |
|
65 | 65 | ]; |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @var array |
69 | 69 | */ |
70 | 70 | protected static $mainCommands = [ |
71 | - ['G', 'config', 'printConfig'], |
|
72 | - ['L', 'list', 'printCategories'], |
|
73 | - ['C', 'check', 'checkIP'], |
|
74 | - ['K', 'check-block', 'checkBlock'], |
|
75 | - ['R', 'report', 'reportIP'], |
|
76 | - ['V', 'bulk-report', 'bulkReport'], |
|
77 | - ['B', 'blacklist', 'getBlacklist'], |
|
78 | - ['E', 'clear', 'clearIP'], |
|
71 | + ['G', 'config', 'printConfig'], |
|
72 | + ['L', 'list', 'printCategories'], |
|
73 | + ['C', 'check', 'checkIP'], |
|
74 | + ['K', 'check-block', 'checkBlock'], |
|
75 | + ['R', 'report', 'reportIP'], |
|
76 | + ['V', 'bulk-report', 'bulkReport'], |
|
77 | + ['B', 'blacklist', 'getBlacklist'], |
|
78 | + ['E', 'clear', 'clearIP'], |
|
79 | 79 | ]; |
80 | 80 | |
81 | 81 | /** |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected static function parseCommand(array $arguments, string $keyPath) |
92 | 92 | { |
93 | - foreach( self::$basicCommands as $cmd){ |
|
94 | - if (self::inArguments($arguments, $cmd[0], $cmd[1])){ |
|
95 | - call_user_func(__NAMESPACE__ .'\AbuseIPDBClient::' . $cmd[2], $cmd[2]=== 'registerApiKey' ? $arguments : null); |
|
93 | + foreach (self::$basicCommands as $cmd) { |
|
94 | + if (self::inArguments($arguments, $cmd[0], $cmd[1])) { |
|
95 | + call_user_func(__NAMESPACE__.'\AbuseIPDBClient::'.$cmd[2], $cmd[2] === 'registerApiKey' ? $arguments : null); |
|
96 | 96 | return true; |
97 | 97 | } |
98 | 98 | } |
99 | - foreach( self::$mainCommands as $cmd){ |
|
100 | - if (self::inArguments($arguments, $cmd[0], $cmd[1])){ |
|
99 | + foreach (self::$mainCommands as $cmd) { |
|
100 | + if (self::inArguments($arguments, $cmd[0], $cmd[1])) { |
|
101 | 101 | self::createHandler($keyPath); |
102 | 102 | self::setOutputFormat($arguments); |
103 | - call_user_func(__NAMESPACE__ .'\AbuseIPDBClient::' . $cmd[2], $arguments); |
|
103 | + call_user_func(__NAMESPACE__.'\AbuseIPDBClient::'.$cmd[2], $arguments); |
|
104 | 104 | return true; |
105 | 105 | } |
106 | 106 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | { |
122 | 122 | $given = self::getArgumentValue($arguments, 'o', 'output') ?? 'default'; |
123 | 123 | $output = empty($given) ? 'default' : $given; |
124 | - self::validate(in_array($output, ['default', 'json', 'plaintext']),'Invalid output argument given.'); |
|
125 | - self::$outputFormat = $output ; |
|
124 | + self::validate(in_array($output, ['default', 'json', 'plaintext']), 'Invalid output argument given.'); |
|
125 | + self::$outputFormat = $output; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | protected static function createHandler(string $keyPath) |
140 | 140 | { |
141 | 141 | self::$keyPath = $keyPath; |
142 | - self::validate( self::checkForInstall(), 'Key file missing.'); |
|
142 | + self::validate(self::checkForInstall(), 'Key file missing.'); |
|
143 | 143 | try { |
144 | 144 | self::$api = self::fromConfigFile(self::$keyPath); |
145 | 145 | } catch (\Exception $e) { |
@@ -176,21 +176,21 @@ discard block |
||
176 | 176 | public static function fromConfigFile(string $configPath) |
177 | 177 | { |
178 | 178 | // check file exists |
179 | - if (!file_exists($configPath) || !is_file($configPath)){ |
|
180 | - throw new \InvalidArgumentException('The file [' . $configPath . '] does not exist.'); |
|
179 | + if (!file_exists($configPath) || !is_file($configPath)) { |
|
180 | + throw new \InvalidArgumentException('The file ['.$configPath.'] does not exist.'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // check file is readable |
184 | - if (!is_readable($configPath)){ |
|
185 | - throw new InvalidPermissionException('The file [' . $configPath . '] is not readable.'); |
|
184 | + if (!is_readable($configPath)) { |
|
185 | + throw new InvalidPermissionException('The file ['.$configPath.'] is not readable.'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | $keyConfig = self::loadJsonFile($configPath); |
189 | 189 | $selfIps = []; |
190 | 190 | |
191 | 191 | // Look for other optional config files in the same directory |
192 | - $selfIpsConfigPath = pathinfo($configPath, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . 'self_ips.json'; |
|
193 | - if (file_exists($selfIpsConfigPath)){ |
|
192 | + $selfIpsConfigPath = pathinfo($configPath, PATHINFO_DIRNAME).DIRECTORY_SEPARATOR.'self_ips.json'; |
|
193 | + if (file_exists($selfIpsConfigPath)) { |
|
194 | 194 | $selfIps = self::loadJsonFile($selfIpsConfigPath)->self_ips; |
195 | 195 | } |
196 | 196 |
@@ -386,7 +386,7 @@ |
||
386 | 386 | */ |
387 | 387 | protected static function getNumericParameter(array $arguments, string $shortArg, string $longArg, int $defaultValue) |
388 | 388 | { |
389 | - if (self::inArguments($arguments,$shortArg, $longArg)){ |
|
389 | + if (self::inArguments($arguments,$shortArg, $longArg)){ |
|
390 | 390 | $val = self::getArgumentValue($arguments,$shortArg, $longArg); |
391 | 391 | |
392 | 392 | if (!is_numeric($val)){ |
@@ -82,7 +82,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | */ |
283 | 283 | private static function parseErrors(object $response) |
284 | 284 | { |
285 | - if (isset($response) && isset($response->errors)){ |
|
286 | - switch (self::$outputFormat){ |
|
285 | + if (isset($response) && isset($response->errors)) { |
|
286 | + switch (self::$outputFormat) { |
|
287 | 287 | case self::OUTPUT_DEFAULT: |
288 | 288 | self::printFormattedErrors($response); |
289 | 289 | break; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | protected static function checkForEmpty(object $response) |
314 | 314 | { |
315 | 315 | // check for empty response ? |
316 | - if ( empty($response) || empty($response->data) ){ |
|
316 | + if (empty($response) || empty($response->data)) { |
|
317 | 317 | self::error('An unexpected error occurred.'); |
318 | 318 | return true; |
319 | 319 | } |
@@ -331,24 +331,24 @@ discard block |
||
331 | 331 | protected static function printFormattedErrors(object $response) |
332 | 332 | { |
333 | 333 | // top error badge |
334 | - Console::log(' ' . Console::text(' ERROR ','white', 'red')); |
|
334 | + Console::log(' '.Console::text(' ERROR ', 'white', 'red')); |
|
335 | 335 | |
336 | 336 | $num = 0; |
337 | 337 | // errors is an array, could have more than one error.. |
338 | - foreach ($response->errors as $err){ |
|
338 | + foreach ($response->errors as $err) { |
|
339 | 339 | $num++; |
340 | 340 | |
341 | - Console::log(Console::text(' ✗', 'red') . self::printResult(' Number: ', $num, 'lightyellow','', false)); |
|
342 | - self::printResult(' Status: ', $err->status ?? null, 'lightyellow',''); |
|
341 | + Console::log(Console::text(' ✗', 'red').self::printResult(' Number: ', $num, 'lightyellow', '', false)); |
|
342 | + self::printResult(' Status: ', $err->status ?? null, 'lightyellow', ''); |
|
343 | 343 | |
344 | - if (!empty($err->source) && !empty($err->source->parameter)){ |
|
344 | + if (!empty($err->source) && !empty($err->source->parameter)) { |
|
345 | 345 | self::printResult(' Parameter: ', $err->source->parameter, 'lightyellow'); |
346 | 346 | } |
347 | 347 | self::printResult(' Title: ', $err->title ?? null, 'lightyellow'); |
348 | 348 | self::printResult(' Detail: ', $err->detail ?? null, 'lightyellow'); |
349 | 349 | |
350 | 350 | // separate errors |
351 | - if (count($response->errors) > 1){ |
|
351 | + if (count($response->errors) > 1) { |
|
352 | 352 | Console::log(' ---'); |
353 | 353 | } |
354 | 354 | |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | */ |
368 | 368 | protected static function printPlainTextErrors(object $response) |
369 | 369 | { |
370 | - foreach ($response->errors as $err){ |
|
370 | + foreach ($response->errors as $err) { |
|
371 | 371 | $text = 'Error: '; |
372 | - $text .= !empty($err->title) ? ' title: ' . $err->title : ''; |
|
373 | - $text .= !empty($err->status) ? ' status: ' . $err->status : ''; |
|
374 | - $text .= !empty($err->source) && !empty($err->source->parameter) ? ' parameter: ' . $err->source->parameter : ''; |
|
375 | - $text .= !empty($err->detail) ? ' detail: ' . $err->detail : ''; |
|
372 | + $text .= !empty($err->title) ? ' title: '.$err->title : ''; |
|
373 | + $text .= !empty($err->status) ? ' status: '.$err->status : ''; |
|
374 | + $text .= !empty($err->source) && !empty($err->source->parameter) ? ' parameter: '.$err->source->parameter : ''; |
|
375 | + $text .= !empty($err->detail) ? ' detail: '.$err->detail : ''; |
|
376 | 376 | $text .= PHP_EOL; |
377 | 377 | echo $text; |
378 | 378 | } |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | { |
392 | 392 | if (self::isDefaultOuput()) { |
393 | 393 | // ✗ |
394 | - Console::log(' ' . Console::text(' ERROR ','white', 'red')); |
|
394 | + Console::log(' '.Console::text(' ERROR ', 'white', 'red')); |
|
395 | 395 | Console::log( |
396 | - Console::text(' ✗', 'red') . |
|
397 | - Console::text(' Detail: ', 'white') . |
|
398 | - Console::text($error, 'lightyellow') . |
|
396 | + Console::text(' ✗', 'red'). |
|
397 | + Console::text(' Detail: ', 'white'). |
|
398 | + Console::text($error, 'lightyellow'). |
|
399 | 399 | Console::text('', 'white') |
400 | 400 | ); |
401 | 401 | Console::log(); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | */ |
416 | 416 | protected static function validate(bool $condition, string $message, bool $print = true) |
417 | 417 | { |
418 | - if ( !$condition ){ |
|
418 | + if (!$condition) { |
|
419 | 419 | if ($print && self::isDefaultOuput()) { |
420 | 420 | Console::log(); |
421 | 421 | self::error($message); |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | */ |
440 | 440 | protected static function getNumericParameter(array $arguments, string $shortArg, string $longArg, int $defaultValue) |
441 | 441 | { |
442 | - if (self::inArguments($arguments,$shortArg, $longArg)){ |
|
443 | - $val = self::getArgumentValue($arguments,$shortArg, $longArg); |
|
442 | + if (self::inArguments($arguments, $shortArg, $longArg)) { |
|
443 | + $val = self::getArgumentValue($arguments, $shortArg, $longArg); |
|
444 | 444 | |
445 | - if (!is_numeric($val)){ |
|
445 | + if (!is_numeric($val)) { |
|
446 | 446 | self::error("Invalid parameter: $longArg must be a numeric value."); |
447 | 447 | self::printFooter(); |
448 | 448 | Program::exit(1); |
@@ -65,13 +65,13 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -64,16 +64,16 @@ |
||
64 | 64 | Console::log(Console::text(' ' . $savedIcon, $savedColor) . self::printResult(' Saved reports: ', $nbSavedReports, $savedColor, '', false)); |
65 | 65 | } |
66 | 66 | |
67 | - /** |
|
68 | - * Print report errors |
|
69 | - * |
|
70 | - * @access protected |
|
71 | - * @static |
|
72 | - * @param object $response |
|
73 | - * @param string $fileName |
|
74 | - * |
|
75 | - * @return void |
|
76 | - */ |
|
67 | + /** |
|
68 | + * Print report errors |
|
69 | + * |
|
70 | + * @access protected |
|
71 | + * @static |
|
72 | + * @param object $response |
|
73 | + * @param string $fileName |
|
74 | + * |
|
75 | + * @return void |
|
76 | + */ |
|
77 | 77 | protected static function printBulkReportErrors(object $response) |
78 | 78 | { |
79 | 79 | $nbErrorReports = isset($response->data->invalidReports) ? count($response->data->invalidReports) : 0; |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | protected static function printBulkReportDetail(string $fileName) |
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 |
||
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 |
||
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 |
@@ -171,7 +171,7 @@ discard block |
||
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 |
||
206 | 206 | } |
207 | 207 | } |
208 | 208 | return $categories; |
209 | - } |
|
209 | + } |
|
210 | 210 | } |
211 | 211 | \ No newline at end of file |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | protected static function printCheckScore(object $response) |
42 | 42 | { |
43 | 43 | $score = empty($response->data->abuseConfidenceScore) ? 0 : $response->data->abuseConfidenceScore; |
44 | - $line = Console::text(Console::pad(' Confidence score:', 23), 'white') . self::getScoreBadge($score); |
|
44 | + $line = Console::text(Console::pad(' Confidence score:', 23), 'white').self::getScoreBadge($score); |
|
45 | 45 | Console::log($line); |
46 | 46 | } |
47 | 47 | |
@@ -60,26 +60,26 @@ discard block |
||
60 | 60 | // self::printResult(' isPublic', $response->data->isPublic, $defaultColor); |
61 | 61 | // self::printResult(' ipVersion', $response->data->ipVersion, $defaultColor); |
62 | 62 | |
63 | - $line = self::printResult(Console::pad(' Whitelisted:', 23), $response->data->isWhitelisted ? 'true': 'false', $color, '', false); |
|
63 | + $line = self::printResult(Console::pad(' Whitelisted:', 23), $response->data->isWhitelisted ? 'true' : 'false', $color, '', false); |
|
64 | 64 | $line .= $response->data->isWhitelisted ? Console::text(' ★', 'green') : ''; |
65 | 65 | Console::log($line); |
66 | 66 | |
67 | 67 | self::printResult(Console::pad(' Country code:', 23), $response->data->countryCode, $color); |
68 | 68 | |
69 | - if (!empty($response->data->countryName)){ |
|
69 | + if (!empty($response->data->countryName)) { |
|
70 | 70 | self::printResult(Console::pad(' Country name:', 23), $response->data->countryName, $color); |
71 | 71 | } |
72 | 72 | |
73 | 73 | self::printResult(Console::pad(' ISP:', 23), $response->data->isp, $color); |
74 | 74 | |
75 | - if ($response->data->usageType){ |
|
75 | + if ($response->data->usageType) { |
|
76 | 76 | $line = self::printResult(Console::pad(' Usage type:', 23), $response->data->usageType, $color, '', false); |
77 | 77 | $line .= $response->data->usageType === 'Reserved' ? Console::text(' ◆', 'green') : ''; |
78 | 78 | Console::log($line); |
79 | 79 | } |
80 | 80 | |
81 | 81 | $hostames = implode(', ', array_filter($response->data->hostnames)) ?? null; |
82 | - if (!empty($hostames)){ |
|
82 | + if (!empty($hostames)) { |
|
83 | 83 | self::printResult(Console::pad(' Hostname(s):', 23), $hostames, $color); |
84 | 84 | } |
85 | 85 | |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | { |
102 | 102 | $nbReport = $response->data->totalReports && is_numeric($response->data->totalReports) ? intval($response->data->totalReports) : 0; |
103 | 103 | |
104 | - if ($nbReport > 0 ){ |
|
104 | + if ($nbReport > 0) { |
|
105 | 105 | $line = self::printResult(Console::pad(' Total reports:', 23), $nbReport, $color, '', false); |
106 | 106 | $line .= self::printResult(' from ', $response->data->numDistinctUsers, $color, '', false); |
107 | - $line .= Console::text($nbReport > 0 ? ' distinct users': ' user', 'white'); |
|
107 | + $line .= Console::text($nbReport > 0 ? ' distinct users' : ' user', 'white'); |
|
108 | 108 | Console::log($line); |
109 | 109 | |
110 | 110 | } else { |
111 | 111 | // no reports |
112 | - $day = $maxAge > 1 ? 'in last '. $maxAge . ' days': ' today'; |
|
113 | - Console::log( Console::text(' ✓', 'green') . Console::text(' Not reported ' . $day)); |
|
112 | + $day = $maxAge > 1 ? 'in last '.$maxAge.' days' : ' today'; |
|
113 | + Console::log(Console::text(' ✓', 'green').Console::text(' Not reported '.$day)); |
|
114 | 114 | } |
115 | 115 | |
116 | - if (!empty($response->data->lastReportedAt)){ |
|
116 | + if (!empty($response->data->lastReportedAt)) { |
|
117 | 117 | self::printResult(Console::pad(' Last reported at:', 23), self::getDate($response->data->lastReportedAt), $color); |
118 | 118 | } |
119 | 119 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | { |
134 | 134 | $nbLastReports = isset($response->data->reports) ? count($response->data->reports) : 0; |
135 | 135 | |
136 | - if ($nbLastReports > 0){ |
|
136 | + if ($nbLastReports > 0) { |
|
137 | 137 | Console::log(' Last reports:', 'white'); |
138 | 138 | $numberDiplayedReports = 0; |
139 | 139 | $defaultColor = 'lightyellow'; // reset color for last reports |
140 | 140 | |
141 | - foreach ($response->data->reports as $report){ |
|
141 | + foreach ($response->data->reports as $report) { |
|
142 | 142 | self::printLastReport($report); |
143 | 143 | $numberDiplayedReports++; |
144 | 144 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $line .= Console::text($numberDiplayedReports, $defaultColor); |
148 | 148 | $line .= Console::text('/', 'white'); |
149 | 149 | $line .= Console::text($nbLastReports, $defaultColor); |
150 | - $line .= Console::text($numberDiplayedReports > 1 ? ' reports displayed)': ' report displayed)', 'white'); |
|
150 | + $line .= Console::text($numberDiplayedReports > 1 ? ' reports displayed)' : ' report displayed)', 'white'); |
|
151 | 151 | Console::log($line); |
152 | 152 | break; |
153 | 153 | } |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | $line = Console::text(' →', $defaultColor); |
173 | 173 | $line .= self::printResult(' reported at: ', self::getDate($report->reportedAt), $defaultColor, '', false); |
174 | 174 | // $line .= self::printResult(' by user: ', $report->reporterId, $defaultColor, '', false); |
175 | - if (isset($report->reporterCountryCode) && isset($report->reporterCountryName)){ |
|
175 | + if (isset($report->reporterCountryCode) && isset($report->reporterCountryName)) { |
|
176 | 176 | $line .= Console::text(' from: ', 'white'); |
177 | 177 | $line .= self::printResult('', $report->reporterCountryCode, $defaultColor, '', false); |
178 | 178 | $line .= Console::text(' - ', 'white'); |
179 | 179 | $line .= self::printResult('', $report->reporterCountryName, $defaultColor, '', false); |
180 | 180 | } |
181 | - $line .= Console::text(' with categor' . (count($categories) > 1 ? "ies: " : "y: "), 'white'); |
|
181 | + $line .= Console::text(' with categor'.(count($categories) > 1 ? "ies: " : "y: "), 'white'); |
|
182 | 182 | foreach ($categories as $key => $cat) { |
183 | - $line .= Console::text($key==0 ? '' : ',' , 'white') . Console::text($cat, $defaultColor); |
|
183 | + $line .= Console::text($key == 0 ? '' : ',', 'white').Console::text($cat, $defaultColor); |
|
184 | 184 | } |
185 | 185 | Console::log($line); |
186 | 186 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | private static function getLastReportsCategories(object $report) |
200 | 200 | { |
201 | 201 | $categories = []; |
202 | - foreach (array_filter($report->categories) as $catId){ |
|
202 | + foreach (array_filter($report->categories) as $catId) { |
|
203 | 203 | $cat = ApiHandler::getCategoryNamebyId($catId)[0]; |
204 | 204 | if ($cat !== false) { |
205 | 205 | $categories[] = $cat; |