@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | |
| 4 | -\spl_autoload_register(function (string $class) : void { |
|
| 4 | +\spl_autoload_register(function(string $class) : void { |
|
| 5 | 5 | $classes = [ |
| 6 | 6 | 'hexydec\\agentzero\\apps' => __DIR__.'/mappings/apps.php', |
| 7 | 7 | 'hexydec\\agentzero\\architectures' => __DIR__.'/mappings/architectures.php', |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | namespace hexydec\agentzero; |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public static function get() : array { |
| 16 | 16 | $fn = [ |
| 17 | - 'appslash' => function (string $value) : ?array { |
|
| 17 | + 'appslash' => function(string $value) : ?array { |
|
| 18 | 18 | if (!\str_starts_with($value, 'AppleWebKit') && !\str_contains($value, '://')) { |
| 19 | 19 | $parts = \explode('/', $value, 2); |
| 20 | 20 | return [ |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | ], |
| 33 | 33 | 'Instagram' => [ |
| 34 | 34 | 'match' => 'any', |
| 35 | - 'categories' => function (string $value, int $i, array $tokens) : array { |
|
| 35 | + 'categories' => function(string $value, int $i, array $tokens) : array { |
|
| 36 | 36 | $data = [ |
| 37 | 37 | 'app' => 'Instagram', |
| 38 | 38 | 'appversion' => \explode(' ', $value, 3)[1] ?? null |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // special parser for Facebook app because it is completely different to any other |
| 80 | 80 | 'FBAN/' => [ |
| 81 | 81 | 'match' => 'start', |
| 82 | - 'categories' => function (string $value) : array { |
|
| 82 | + 'categories' => function(string $value) : array { |
|
| 83 | 83 | $map = [ |
| 84 | 84 | 'FBAN/MessengerLiteForiOS' => [ |
| 85 | 85 | 'type' => 'human', |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | ], |
| 153 | 153 | 'FBDM/' => [ |
| 154 | 154 | 'match' => 'start', |
| 155 | - 'categories' => function (string $value) : array { |
|
| 155 | + 'categories' => function(string $value) : array { |
|
| 156 | 156 | $data = []; |
| 157 | 157 | foreach (\explode(',', \trim(\mb_substr($value, 5), '{}')) AS $item) { |
| 158 | 158 | $parts = \explode('=', $item); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | namespace hexydec\agentzero; |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | 'crawler' => fn (string $value) : array => self::getApp($value, ['category' => 'crawler']), |
| 47 | 47 | 'monitor' => fn (string $value) : array => self::getApp($value, ['category' => 'monitor']), |
| 48 | 48 | 'scraper' => fn (string $value) : array => self::getApp($value, ['category' => 'scraper']), |
| 49 | - 'map' => function (string $value, int $i, array $tokens) : ?array { |
|
| 49 | + 'map' => function(string $value, int $i, array $tokens) : ?array { |
|
| 50 | 50 | if (!\str_contains($value, '://')) { // bot will be in the URL |
| 51 | 51 | $parts = \explode('/', $value, 2); |
| 52 | 52 | $category = [ |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | ], |
| 172 | 172 | 'Pingdom.com' => [ |
| 173 | 173 | 'match' => 'start', |
| 174 | - 'categories' => function (string $value) : array { |
|
| 174 | + 'categories' => function(string $value) : array { |
|
| 175 | 175 | $version = \explode('_', \trim($value, '_')); |
| 176 | 176 | return [ |
| 177 | 177 | 'type' => 'robot', |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | ], |
| 253 | 253 | 'Microsoft Office' => [ |
| 254 | 254 | 'match' => 'start', |
| 255 | - 'categories' => function (string $value, int $i, array $tokens) : array { |
|
| 255 | + 'categories' => function(string $value, int $i, array $tokens) : array { |
|
| 256 | 256 | $data = [ |
| 257 | 257 | 'type' => 'robot', |
| 258 | 258 | 'category' => 'feed' |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | namespace hexydec\agentzero; |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | return [ |
| 17 | 17 | '{' => [ |
| 18 | 18 | 'match' => 'any', |
| 19 | - 'categories' => function (string $value) : ?array { |
|
| 19 | + 'categories' => function(string $value) : ?array { |
|
| 20 | 20 | if (($start = \mb_strpos($value, '{')) === false) { |
| 21 | 21 | |
| 22 | 22 | } elseif (($end = \mb_strpos($value, '}', $start)) !== false) { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | namespace hexydec\agentzero; |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public static function get() : array { |
| 16 | 16 | $fn = [ |
| 17 | - 'ios' => function (string $value, int $i, array $tokens) : array { |
|
| 17 | + 'ios' => function(string $value, int $i, array $tokens) : array { |
|
| 18 | 18 | $version = null; |
| 19 | 19 | $model = null; |
| 20 | 20 | foreach ($tokens AS $item) { |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | 'category' => 'console', |
| 46 | 46 | 'vendor' => 'Microsoft', |
| 47 | 47 | ], |
| 48 | - 'playstation' => function (string $value) : array { |
|
| 48 | + 'playstation' => function(string $value) : array { |
|
| 49 | 49 | $parts = \explode(' ', $value); |
| 50 | 50 | if (\str_contains($parts[1], '/')) { |
| 51 | 51 | list($parts[1], $parts[2]) = \explode('/', $parts[1]); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | ], |
| 284 | 284 | 'SAMSUNG-' => [ |
| 285 | 285 | 'match' => 'start', |
| 286 | - 'categories' => function (string $value) : array { |
|
| 286 | + 'categories' => function(string $value) : array { |
|
| 287 | 287 | $parts = \explode('/', $value, 2); |
| 288 | 288 | return [ |
| 289 | 289 | 'device' => \mb_substr($parts[0], 8), |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | ], |
| 309 | 309 | 'SonyEricsson' => [ |
| 310 | 310 | 'match' => 'start', |
| 311 | - 'categories' => function (string $value) : array { |
|
| 311 | + 'categories' => function(string $value) : array { |
|
| 312 | 312 | $parts = \explode('/', $value, 2); |
| 313 | 313 | return [ |
| 314 | 314 | 'type' => 'human', |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | ], |
| 322 | 322 | 'LGE' => [ |
| 323 | 323 | 'match' => 'exact', |
| 324 | - 'categories' => function (string $value, int $i, array $tokens) : array { |
|
| 324 | + 'categories' => function(string $value, int $i, array $tokens) : array { |
|
| 325 | 325 | $device = $tokens[++$i] ?? null; |
| 326 | 326 | $platformversion = $tokens[++$i] ?? null; |
| 327 | 327 | $build = $tokens[++$i] ?? null; |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | ], |
| 338 | 338 | 'NOKIA' => [ |
| 339 | 339 | 'match' => 'start', |
| 340 | - 'categories' => function (string $value) : array { |
|
| 340 | + 'categories' => function(string $value) : array { |
|
| 341 | 341 | $parts = \explode('/', $value, 2); |
| 342 | 342 | $device = \trim(\mb_substr($parts[0], 5, \str_ends_with($parts[0], ' Build') ? -6 : null)); |
| 343 | 343 | return [ |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | ], |
| 378 | 378 | 'ThinkPad' => [ |
| 379 | 379 | 'match' => 'start', |
| 380 | - 'categories' => function (string $value, int $i, array $tokens) : array { |
|
| 380 | + 'categories' => function(string $value, int $i, array $tokens) : array { |
|
| 381 | 381 | if (\mb_strpos($tokens[++$i] ?? '', 'Build/') === 0) { |
| 382 | 382 | $device = \explode('_', \mb_substr($tokens[$i], 6)); |
| 383 | 383 | } |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | ], |
| 399 | 399 | 'Build/' => [ |
| 400 | 400 | 'match' => 'any', |
| 401 | - 'categories' => function (string $value) : array { |
|
| 401 | + 'categories' => function(string $value) : array { |
|
| 402 | 402 | return self::getDevice($value); |
| 403 | 403 | } |
| 404 | 404 | ], |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | namespace hexydec\agentzero; |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | namespace hexydec\agentzero; |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public static function get() : array { |
| 16 | 16 | $fn = [ |
| 17 | - 'platformspace' => function (string $value) : array { |
|
| 17 | + 'platformspace' => function(string $value) : array { |
|
| 18 | 18 | $parts = \explode(' ', $value, 2); |
| 19 | 19 | return [ |
| 20 | 20 | 'platform' => $parts[0], |
| 21 | 21 | 'platformversion' => $parts[1] ?? null |
| 22 | 22 | ]; |
| 23 | 23 | }, |
| 24 | - 'platformlinux' => function (string $value) : array { |
|
| 24 | + 'platformlinux' => function(string $value) : array { |
|
| 25 | 25 | if (!\str_starts_with($value, 'Red Hat/') && ($platform = \mb_strstr($value, ' ', true)) !== false) { |
| 26 | 26 | $value = $platform; |
| 27 | 27 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'platformversion' => isset($parts[1]) && \strspn($parts[1], '0123456789.-_') > 0 ? $parts[1] : null |
| 41 | 41 | ]; |
| 42 | 42 | }, |
| 43 | - 'platformwindows' => function (string $value) : array { |
|
| 43 | + 'platformwindows' => function(string $value) : array { |
|
| 44 | 44 | $mapping = [ |
| 45 | 45 | '5.0' => '2000', |
| 46 | 46 | '5.1' => 'XP', |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | ], |
| 78 | 78 | 'Windows Phone' => [ |
| 79 | 79 | 'match' => 'start', |
| 80 | - 'categories' => function (string $value) : array { |
|
| 80 | + 'categories' => function(string $value) : array { |
|
| 81 | 81 | $version = \mb_substr($value, 14); |
| 82 | 82 | return [ |
| 83 | 83 | 'type' => 'human', |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | ], |
| 119 | 119 | 'Mac OS X' => [ |
| 120 | 120 | 'match' => 'any', |
| 121 | - 'categories' => function (string $value) : array { |
|
| 121 | + 'categories' => function(string $value) : array { |
|
| 122 | 122 | $version = \str_replace('_', '.', \mb_substr($value, \mb_stripos($value, 'Mac OS X') + 9)); |
| 123 | 123 | $register = $version && \intval(\explode('.', $version)[1] ?? 0) >= 6 ? 64 : null; |
| 124 | 124 | return [ |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | ], |
| 153 | 153 | 'CrOS' => [ |
| 154 | 154 | 'match' => 'start', |
| 155 | - 'categories' => function (string $value) : array { |
|
| 155 | + 'categories' => function(string $value) : array { |
|
| 156 | 156 | $parts = \explode(' ', $value); |
| 157 | 157 | return [ |
| 158 | 158 | 'type' => 'human', |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | ], |
| 174 | 174 | 'Tizen' => [ |
| 175 | 175 | 'match' => 'start', |
| 176 | - 'categories' => function (string $value) : array { |
|
| 176 | + 'categories' => function(string $value) : array { |
|
| 177 | 177 | $parts = \explode(' ', $value, 2); |
| 178 | 178 | return [ |
| 179 | 179 | 'type' => 'human', |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | ], |
| 277 | 277 | 'AmigaOS' => [ |
| 278 | 278 | 'match' => 'any', |
| 279 | - 'categories' => function (string $value) : array { |
|
| 279 | + 'categories' => function(string $value) : array { |
|
| 280 | 280 | if (($pos = \mb_stripos($value, 'AmigaOS')) !== false) { |
| 281 | 281 | $value = \mb_substr($value, $pos); |
| 282 | 282 | } |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | ], |
| 293 | 293 | 'Fuchsia' => [ |
| 294 | 294 | 'match' => 'exact', |
| 295 | - 'categories' => function (string $value, int $i, array $tokens) : array { |
|
| 295 | + 'categories' => function(string $value, int $i, array $tokens) : array { |
|
| 296 | 296 | $os = \explode(' ', $tokens[++$i], 2); |
| 297 | 297 | return [ |
| 298 | 298 | 'type' => 'human', |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | ], |
| 306 | 306 | 'Maemo' => [ |
| 307 | 307 | 'match' => 'exact', |
| 308 | - 'categories' => function (string $value, int $i, array $tokens) : array { |
|
| 308 | + 'categories' => function(string $value, int $i, array $tokens) : array { |
|
| 309 | 309 | $os = \explode(' ', $tokens[++$i], 2); |
| 310 | 310 | return [ |
| 311 | 311 | 'type' => 'human', |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | ], |
| 328 | 328 | 'Haiku' => [ |
| 329 | 329 | 'match' => 'any', |
| 330 | - 'categories' => function (string $value) : array { |
|
| 330 | + 'categories' => function(string $value) : array { |
|
| 331 | 331 | $parts = \explode('/', $value, 2); |
| 332 | 332 | return [ |
| 333 | 333 | 'type' => 'human', |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | ], |
| 341 | 341 | 'BeOS' => [ |
| 342 | 342 | 'match' => 'start', |
| 343 | - 'categories' => function (string $value) : array { |
|
| 343 | + 'categories' => function(string $value) : array { |
|
| 344 | 344 | $parts = \explode('/', $value, 2); |
| 345 | 345 | return [ |
| 346 | 346 | 'type' => 'human', |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | ], |
| 354 | 354 | 'Android' => [ |
| 355 | 355 | 'match' => 'start', |
| 356 | - 'categories' => function (string $value, int $i, array $tokens) : array { |
|
| 356 | + 'categories' => function(string $value, int $i, array $tokens) : array { |
|
| 357 | 357 | $os = \explode(' ', $value, 3); |
| 358 | 358 | $device = empty($tokens[++$i]) || \strlen($tokens[$i]) <= 2 ? [] : devices::getDevice($tokens[$i]); |
| 359 | 359 | return \array_merge($device, [ |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | ], |
| 375 | 375 | 'X11' => [ |
| 376 | 376 | 'match' => 'exact', |
| 377 | - 'categories' => function (string $value, int $i, array $tokens) : array { |
|
| 377 | + 'categories' => function(string $value, int $i, array $tokens) : array { |
|
| 378 | 378 | $os = \explode(' ', $tokens[++$i], 2); |
| 379 | 379 | return [ |
| 380 | 380 | 'type' => 'human', |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | namespace hexydec\agentzero; |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public static function get() : array { |
| 16 | 16 | $fn = [ |
| 17 | - 'browserslash' => function (string $value) : array { |
|
| 17 | + 'browserslash' => function(string $value) : array { |
|
| 18 | 18 | if (($browser = \mb_strrchr($value, ' ')) !== false) { |
| 19 | 19 | $value = \ltrim($browser); |
| 20 | 20 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | 'browserversion' => $parts[1] ?? null |
| 32 | 32 | ]; |
| 33 | 33 | }, |
| 34 | - 'presto' => function (string $value) : array { |
|
| 34 | + 'presto' => function(string $value) : array { |
|
| 35 | 35 | $parts = \explode('/', $value, 2); |
| 36 | 36 | return [ |
| 37 | 37 | 'type' => 'human', |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | ], |
| 210 | 210 | 'Midori' => [ |
| 211 | 211 | 'match' => 'start', |
| 212 | - 'categories' => function (string $value) : array { |
|
| 212 | + 'categories' => function(string $value) : array { |
|
| 213 | 213 | $parts = \explode('/', $value, 2); |
| 214 | 214 | return [ |
| 215 | 215 | 'browser' => 'Midori', |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | namespace hexydec\agentzero; |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | ]; |
| 138 | 138 | $fn = [ |
| 139 | 139 | 'match' => 'start', |
| 140 | - 'categories' => function (string $value, int $i , array $tokens, string $match) : ?array { |
|
| 140 | + 'categories' => function(string $value, int $i, array $tokens, string $match) : ?array { |
|
| 141 | 141 | if ($value === $match) { |
| 142 | 142 | return ['language' => $value]; |
| 143 | 143 | } else { |