@@ -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 | class special { |
@@ -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 | class frameworks { |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | 'framework' => 'Alamofire', |
| 27 | 27 | 'frameworkversion' => \explode('/', $value, 3)[1] |
| 28 | 28 | ]), |
| 29 | - '.NET CLR ' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 29 | + '.NET CLR ' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 30 | 30 | |
| 31 | 31 | // find latest version as often specifdies many versions |
| 32 | 32 | $levels = []; |
@@ -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 | class crawlers { |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | 'category' => 'feed' |
| 218 | 218 | ] |
| 219 | 219 | )), |
| 220 | - 'crawler' => function (string $value) : array { |
|
| 220 | + 'crawler' => function(string $value) : array { |
|
| 221 | 221 | return self::getApp($value, ['category' => 'crawler']); |
| 222 | 222 | }, |
| 223 | 223 | 'monitor' => fn (string $value) : array => self::getApp($value, ['category' => 'monitor']), |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | 'type' => 'robot', |
| 230 | 230 | 'categpry' => 'scraper' |
| 231 | 231 | ]), |
| 232 | - 'Moblie' => new props('exact', [ // some samsung devices mispelt it |
|
| 232 | + 'Moblie' => new props('exact', [// some samsung devices mispelt it |
|
| 233 | 233 | 'type' => 'robot', |
| 234 | 234 | 'category' => 'scraper' |
| 235 | 235 | ]), |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | 'Siteimprove.com' => new props('any', $fn['crawler']), |
| 255 | 255 | 'SEOlyt/' => new props('any', $fn['crawler']), |
| 256 | 256 | 'CyotekWebCopy' => new props('start', $fn['scraper']), |
| 257 | - 'Yandex' => new props('start', function (string $value) : array { |
|
| 257 | + 'Yandex' => new props('start', function(string $value) : array { |
|
| 258 | 258 | $parts = \explode('/', $value, 3); |
| 259 | 259 | return [ |
| 260 | 260 | 'type' => 'robot', |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | ]; |
| 266 | 266 | }), |
| 267 | 267 | 'Google Page Speed Insights' => new props('exact', $fn['validator']), |
| 268 | - 'Qwantify' => new props('start', function (string $value) : array { |
|
| 268 | + 'Qwantify' => new props('start', function(string $value) : array { |
|
| 269 | 269 | $parts = \explode('/', $value, 3); |
| 270 | 270 | return [ |
| 271 | 271 | 'type' => 'robot', |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | 'HostTracker/' => new props('start', $fn['monitor']), |
| 317 | 317 | 'NCSC Web Check [email protected]' => new props('exact', $fn['monitor']), |
| 318 | 318 | 'Enhanced WebCheck [email protected]' => new props('exact', $fn['monitor']), |
| 319 | - 'Pingdom.com' => new props('start', function (string $value) : array { |
|
| 319 | + 'Pingdom.com' => new props('start', function(string $value) : array { |
|
| 320 | 320 | $version = \explode('_', \trim($value, '_')); |
| 321 | 321 | return [ |
| 322 | 322 | 'type' => 'robot', |
@@ -346,14 +346,14 @@ discard block |
||
| 346 | 346 | 'Embedly/' => new props('start', $fn['feed']), |
| 347 | 347 | 'PayPal IPN' => new props('exact', $fn['feed']), |
| 348 | 348 | 'DropboxPreviewBot/' => new props('start', $fn['feed']), |
| 349 | - 'Pleroma' => new props('start', fn (string $value) : array => [ // mastodon |
|
| 349 | + 'Pleroma' => new props('start', fn (string $value) : array => [// mastodon |
|
| 350 | 350 | 'type' => 'robot', |
| 351 | 351 | 'category' => 'feed', |
| 352 | 352 | 'app' => 'Mastodon', |
| 353 | 353 | 'appname' => 'Pleroma', |
| 354 | 354 | 'appversion' => \mb_substr($value, 8) |
| 355 | 355 | ]), |
| 356 | - 'Outlook-Android/' => new props('start', fn (string $value) : array => [ // mastodon |
|
| 356 | + 'Outlook-Android/' => new props('start', fn (string $value) : array => [// mastodon |
|
| 357 | 357 | 'type' => 'robot', |
| 358 | 358 | 'category' => 'feed', |
| 359 | 359 | 'app' => 'Outlook', |
@@ -361,13 +361,13 @@ discard block |
||
| 361 | 361 | 'platform' => 'Android', |
| 362 | 362 | 'appversion' => \mb_substr($value, 16) |
| 363 | 363 | ]), |
| 364 | - 'Outlook-iOS/' => new props('start', fn (string $value, int $i, array $tokens) : array => [ // mastodon |
|
| 364 | + 'Outlook-iOS/' => new props('start', fn (string $value, int $i, array $tokens) : array => [// mastodon |
|
| 365 | 365 | 'type' => 'robot', |
| 366 | 366 | 'category' => 'feed', |
| 367 | 367 | 'app' => 'Outlook', |
| 368 | 368 | 'appname' => 'Outlook-iOS', |
| 369 | 369 | 'platform' => 'iOS', |
| 370 | - 'appversion' => $tokens[$i+1] ?? \mb_substr($value, 12) |
|
| 370 | + 'appversion' => $tokens[$i + 1] ?? \mb_substr($value, 12) |
|
| 371 | 371 | ]), |
| 372 | 372 | 'OutlookMobileCloudService-Autodetect/' => new props('start', fn (string $value) : array => [ |
| 373 | 373 | 'type' => 'robot', |
@@ -376,12 +376,12 @@ discard block |
||
| 376 | 376 | 'appname' => 'OutlookMobileCloudService-Autodetect', |
| 377 | 377 | 'appversion' => \mb_substr($value, 37) |
| 378 | 378 | ]), |
| 379 | - 'HubSpot Connect ' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 379 | + 'HubSpot Connect ' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 380 | 380 | $app = 'HubSpot Connect'; |
| 381 | 381 | $count = \count($tokens); |
| 382 | 382 | for ($n = $i; $n < $count; $n++) { |
| 383 | 383 | if (\str_starts_with($tokens[$n], 'namespace: ')) { |
| 384 | - $app = \mb_substr($tokens[$n], 11).' - '.$tokens[$n+1]; |
|
| 384 | + $app = \mb_substr($tokens[$n], 11).' - '.$tokens[$n + 1]; |
|
| 385 | 385 | break; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | 'type' => 'robot', |
| 413 | 413 | 'category' => 'feed', |
| 414 | 414 | 'app' => 'Google Docs', |
| 415 | - 'appname' => $value.'; '.$tokens[$i+1] |
|
| 415 | + 'appname' => $value.'; '.$tokens[$i + 1] |
|
| 416 | 416 | ]), |
| 417 | 417 | 'Google-Lens' => new props('exact', $fn['feed']), |
| 418 | 418 | 'ManicTime/' => new props('start', $fn['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 | class apps { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | public static function get() : array { |
| 13 | 13 | $fn = [ |
| 14 | - 'appslash' => function (string $value, int $i, array $tokens, string $match) : array { |
|
| 14 | + 'appslash' => function(string $value, int $i, array $tokens, string $match) : array { |
|
| 15 | 15 | if (\mb_stripos($value, 'AppleWebKit') === false && !\str_contains($value, '://')) { |
| 16 | 16 | $parts = \explode('/', $value, 4); |
| 17 | 17 | $offset = isset($parts[2]) ? 1 : 0; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | }, |
| 29 | 29 | ]; |
| 30 | 30 | return [ |
| 31 | - 'com.google.' => new props('start', function (string $value) : array { |
|
| 31 | + 'com.google.' => new props('start', function(string $value) : array { |
|
| 32 | 32 | $parts = \explode('/', $value, 3); |
| 33 | 33 | return [ |
| 34 | 34 | 'type' => 'human', |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | 'appversion' => $parts[1] ?? null |
| 38 | 38 | ]; |
| 39 | 39 | }), |
| 40 | - 'OcIdWebView' => new props('exact', function (string $value) : array { |
|
| 40 | + 'OcIdWebView' => new props('exact', function(string $value) : array { |
|
| 41 | 41 | $data = [ |
| 42 | 42 | 'app' => 'Google App Web View', |
| 43 | 43 | 'appname' => $value |
| 44 | 44 | ]; |
| 45 | 45 | return $data; |
| 46 | 46 | }), |
| 47 | - 'Instagram' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
| 47 | + 'Instagram' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
| 48 | 48 | $parts = \explode(' ', $value, 4); |
| 49 | 49 | $data = [ |
| 50 | 50 | 'type' => 'human', |
@@ -114,16 +114,16 @@ discard block |
||
| 114 | 114 | 'appname' => 'Zoom', |
| 115 | 115 | 'appversion' => \mb_substr($value, 5) |
| 116 | 116 | ]), |
| 117 | - 'Reddit/' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 118 | - $os = !empty($tokens[$i+2]) ? \explode('/', $tokens[$i+2], 2) : null; |
|
| 117 | + 'Reddit/' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 118 | + $os = !empty($tokens[$i + 2]) ? \explode('/', $tokens[$i + 2], 2) : null; |
|
| 119 | 119 | $parts = !empty($os[1]) ? \explode(' ', $os[1], 3) : null; |
| 120 | 120 | return [ |
| 121 | 121 | 'type' => 'human', |
| 122 | 122 | 'app' => 'Reddit', |
| 123 | 123 | 'appname' => 'Reddit', |
| 124 | - 'appversion' => $value === 'Reddit/Version' ? (\mb_strstr($tokens[$i+1], '/', true) ?: null) : \mb_substr($value, 7), |
|
| 124 | + 'appversion' => $value === 'Reddit/Version' ? (\mb_strstr($tokens[$i + 1], '/', true) ?: null) : \mb_substr($value, 7), |
|
| 125 | 125 | 'platform' => $parts[0] ?? null, |
| 126 | - 'platformversion' => $tokens[$i+3] ?? null |
|
| 126 | + 'platformversion' => $tokens[$i + 3] ?? null |
|
| 127 | 127 | ]; |
| 128 | 128 | }), |
| 129 | 129 | 'Pinterest for ' => new props('start', fn (string $value) : array => [ |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | 'Instapaper' => new props('start', fn (string $value, int $i, array $tokens, string $match) => \array_merge([ |
| 186 | 186 | 'type' => 'human' |
| 187 | 187 | ], $fn['appslash']($value, $i, $tokens, $match))), |
| 188 | - 'Player/LG' => new props('start', function (string $value, int $i, array $tokens) : ?array { |
|
| 189 | - if (\str_starts_with($tokens[$i+1], 'Player ')) { |
|
| 190 | - $parts = \explode(' ', $tokens[$i+1]); |
|
| 188 | + 'Player/LG' => new props('start', function(string $value, int $i, array $tokens) : ?array { |
|
| 189 | + if (\str_starts_with($tokens[$i + 1], 'Player ')) { |
|
| 190 | + $parts = \explode(' ', $tokens[$i + 1]); |
|
| 191 | 191 | $device = $i === 1 ? \explode('/', $tokens[0]) : null; |
| 192 | 192 | return [ |
| 193 | 193 | 'type' => 'human', |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | 'app' => 'WeChat', |
| 216 | 216 | 'appname' => 'MicroMessenger' |
| 217 | 217 | ]), |
| 218 | - 'weibo' => new props('any', function (string $value) : array { |
|
| 218 | + 'weibo' => new props('any', function(string $value) : array { |
|
| 219 | 219 | $data = [ |
| 220 | 220 | 'app' => 'Weibo', |
| 221 | 221 | 'appname' => 'Weibo' |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | }), |
| 233 | 233 | |
| 234 | 234 | // special parser for Facebook app because it is completely different to any other |
| 235 | - 'FBAN/' => new props('any', function (string $value) : array { |
|
| 235 | + 'FBAN/' => new props('any', function(string $value) : array { |
|
| 236 | 236 | $map = [ |
| 237 | 237 | 'FBAN/MessengerLiteForiOS' => [ |
| 238 | 238 | 'type' => 'human', |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | 'FBMD/' => new props('start', fn (string $value) : array => [ |
| 288 | 288 | 'model' => \mb_substr($value, 5) |
| 289 | 289 | ]), |
| 290 | - 'FBDM/' => new props('start', function (string $value) : array { |
|
| 290 | + 'FBDM/' => new props('start', function(string $value) : array { |
|
| 291 | 291 | $data = []; |
| 292 | 292 | foreach (\explode(',', \trim(\mb_substr($value, 5), '{}')) AS $item) { |
| 293 | 293 | $parts = \explode('=', $item); |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | 'FBSV' => new props('start', fn (string $value) : array => [ |
| 316 | 316 | 'platformversion' => \mb_substr($value, 5) |
| 317 | 317 | ]), |
| 318 | - 'isDarkMode/' => new props('start', function (string $value) : array { |
|
| 318 | + 'isDarkMode/' => new props('start', function(string $value) : array { |
|
| 319 | 319 | $mode = \mb_substr($value, 11); |
| 320 | 320 | return [ |
| 321 | 321 | 'darkmode' => \in_array($mode, ['0', '1'], true) ? \boolval($mode) : null |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | 'NetType/' => new props('start', fn (string $value) : array => [ |
| 328 | 328 | 'nettype' => \mb_convert_case(\mb_substr($value, 8), MB_CASE_UPPER) |
| 329 | 329 | ]), |
| 330 | - 'Microsoft Office' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 330 | + 'Microsoft Office' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 331 | 331 | $data = [ |
| 332 | 332 | 'type' => 'human' |
| 333 | 333 | ]; |
@@ -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 | class urls { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @return array<string,props> An array with keys representing the string to match, and values a props object defining how to generate the match and which properties to set |
| 11 | 11 | */ |
| 12 | 12 | public static function get() : array { |
| 13 | - $fn = function (string $value, int $i, array $tokens) : ?array { |
|
| 13 | + $fn = function(string $value, int $i, array $tokens) : ?array { |
|
| 14 | 14 | if (($start = \stripos($value, 'http://')) === false) { |
| 15 | 15 | if (($start = \stripos($value, 'https://')) === false) { |
| 16 | 16 | $start = \stripos($value, 'www.'); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | 'https://' => new props('any', $fn), |
| 33 | 33 | 'www.' => new props('start', $fn), |
| 34 | 34 | '.com' => new props('any', $fn), |
| 35 | - '.' => new props('any', function (string $value) : ?array { |
|
| 35 | + '.' => new props('any', function(string $value) : ?array { |
|
| 36 | 36 | foreach (\explode(' ', $value) AS $item) { |
| 37 | 37 | if (!\str_starts_with($item, 'com.') && \substr_count($item, '.') >= 2) { |
| 38 | 38 | foreach (\explode('.', $item) AS $part) { |
@@ -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 | class devices { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | public static function get() : array { |
| 13 | 13 | $fn = [ |
| 14 | - 'ios' => function (string $value, int $i, array $tokens) : array { |
|
| 14 | + 'ios' => function(string $value, int $i, array $tokens) : array { |
|
| 15 | 15 | $version = null; |
| 16 | 16 | $model = null; |
| 17 | 17 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | 'device' => 'Xbox', |
| 53 | 53 | 'model' => ($model = \mb_substr($value, 5)) === '' ? null : $model |
| 54 | 54 | ], |
| 55 | - 'playstation' => function (string $value) : array { |
|
| 55 | + 'playstation' => function(string $value) : array { |
|
| 56 | 56 | $parts = \explode(' ', $value); |
| 57 | 57 | if (\str_contains($parts[1], '/')) { |
| 58 | 58 | list($parts[1], $parts[2]) = \explode('/', $parts[1]); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | 'bits' => 64 |
| 76 | 76 | ]; |
| 77 | 77 | }, |
| 78 | - 'firetablet' => function (string $value) : ?array { |
|
| 78 | + 'firetablet' => function(string $value) : ?array { |
|
| 79 | 79 | $model = \explode(' ', $value)[0]; |
| 80 | 80 | if (\ctype_alpha($model) && \mb_strlen($model) <= 7) { |
| 81 | 81 | return [ |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | 'vendor' => 'Google', |
| 193 | 193 | 'platformversion' => \mb_substr($value, 7) |
| 194 | 194 | ]), |
| 195 | - 'Apple/' => new props('start', function (string $value) : array { |
|
| 195 | + 'Apple/' => new props('start', function(string $value) : array { |
|
| 196 | 196 | $value = \mb_substr($value, 6); |
| 197 | 197 | $split = \strcspn($value, '0123456789'); |
| 198 | 198 | $device = \mb_substr($value, 0, $split); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | 'googleweblight' => new props('exact', [ |
| 239 | 239 | 'proxy' => 'googleweblight' |
| 240 | 240 | ]), |
| 241 | - 'SAMSUNG-' => new props('start', function (string $value) : array { |
|
| 241 | + 'SAMSUNG-' => new props('start', function(string $value) : array { |
|
| 242 | 242 | $parts = \explode('/', $value, 2); |
| 243 | 243 | return [ |
| 244 | 244 | 'type' => 'human', |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | 'Samsung' => new props('start', fn (string $value) : ?array => \str_starts_with($value, 'SamsungBrowser') ? null : [ |
| 252 | 252 | 'vendor' => 'Samsung' |
| 253 | 253 | ]), |
| 254 | - 'SM-' => new props('start', function (string $value) : array { |
|
| 254 | + 'SM-' => new props('start', function(string $value) : array { |
|
| 255 | 255 | $parts = \explode('.', \explode(' ', $value)[0]); |
| 256 | 256 | return [ |
| 257 | 257 | 'vendor' => 'Samsung', |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | 'Acer' => new props('start', [ |
| 263 | 263 | 'vendor' => 'Acer' |
| 264 | 264 | ]), |
| 265 | - 'SonyEricsson' => new props('start', function (string $value) : array { |
|
| 265 | + 'SonyEricsson' => new props('start', function(string $value) : array { |
|
| 266 | 266 | $parts = \explode('/', $value, 2); |
| 267 | 267 | return [ |
| 268 | 268 | 'type' => 'human', |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | 'build' => $parts[1] ?? null |
| 273 | 273 | ]; |
| 274 | 274 | }), |
| 275 | - 'LGE' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
| 275 | + 'LGE' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
| 276 | 276 | $device = $tokens[++$i] ?? null; |
| 277 | 277 | $platformversion = empty($tokens[++$i]) ? null : \mb_substr(\explode(' ', $tokens[$i])[0], 5); |
| 278 | 278 | $build = $tokens[++$i] ?? null; |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | 'vendor' => 'LG' |
| 286 | 286 | ]; |
| 287 | 287 | }), |
| 288 | - 'LG-' => new props('start', function (string $value) : array { |
|
| 288 | + 'LG-' => new props('start', function(string $value) : array { |
|
| 289 | 289 | $parts = \explode('/', \mb_substr($value, 3), 3); |
| 290 | 290 | return [ |
| 291 | 291 | 'type' => 'human', |
@@ -317,16 +317,16 @@ discard block |
||
| 317 | 317 | 'vendor' => 'Tecno', |
| 318 | 318 | 'model' => \explode(' ', \str_replace('-', ' ', $value), 2)[1] ?? null |
| 319 | 319 | ]), |
| 320 | - 'Xiaomi' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 320 | + 'Xiaomi' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 321 | 321 | return [ |
| 322 | 322 | 'type' => 'human', |
| 323 | 323 | 'vendor' => 'Xiaomi', |
| 324 | 324 | 'device' => \mb_stripos($value, 'Poco') !== false ? 'Poco' : null, |
| 325 | 325 | 'model' => \mb_stripos($value, 'Xiaomi-Mi') !== 0 ? (\explode(' ', $value)[1] ?? null) : null, |
| 326 | - 'platformversion' => \is_numeric($tokens[$i+1] ?? null) ? $tokens[$i+1] : null |
|
| 326 | + 'platformversion' => \is_numeric($tokens[$i + 1] ?? null) ? $tokens[$i + 1] : null |
|
| 327 | 327 | ]; |
| 328 | 328 | }), |
| 329 | - 'ThinkPad' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 329 | + 'ThinkPad' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 330 | 330 | if (\mb_strpos($tokens[++$i] ?? '', 'Build/') === 0) { |
| 331 | 331 | $device = \explode('_', \mb_substr($tokens[$i], 6)); |
| 332 | 332 | } |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | 'build' => $device[2] ?? null |
| 339 | 339 | ]; |
| 340 | 340 | }), |
| 341 | - 'BlackBerry' => new props('start', function (string $value) : array { |
|
| 341 | + 'BlackBerry' => new props('start', function(string $value) : array { |
|
| 342 | 342 | $parts = \explode('/', $value); |
| 343 | 343 | return [ |
| 344 | 344 | 'type' => 'human', |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | 'model' => \mb_substr($value, 6) |
| 354 | 354 | ]), |
| 355 | 355 | 'Build/' => new props('any', fn (string $value) : array => self::getDevice($value)), |
| 356 | - 'x' => new props('any', function (string $value) : ?array { |
|
| 356 | + 'x' => new props('any', function(string $value) : ?array { |
|
| 357 | 357 | if (\str_contains($value, '@')) { |
| 358 | 358 | $dpi = \explode('@', $value); |
| 359 | 359 | $value = $dpi[0]; |
@@ -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 | class platforms { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | public static function get() : array { |
| 13 | 13 | $fn = [ |
| 14 | - 'platformlinux' => function (string $value) : array { |
|
| 14 | + 'platformlinux' => function(string $value) : array { |
|
| 15 | 15 | if (!\str_starts_with($value, 'Red Hat/') && ($platform = \mb_strstr($value, ' ', true)) !== false) { |
| 16 | 16 | $value = $platform; |
| 17 | 17 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | 'platformversion' => $parts[1] ?? null |
| 31 | 31 | ]; |
| 32 | 32 | }, |
| 33 | - 'platformwindows' => function (string $value) : array { |
|
| 33 | + 'platformwindows' => function(string $value) : array { |
|
| 34 | 34 | $mapping = [ |
| 35 | 35 | '5.0' => '2000', |
| 36 | 36 | '5.1' => 'XP', |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | 'platformversion' => $mapping[$version] ?? $version |
| 57 | 57 | ]; |
| 58 | 58 | }, |
| 59 | - 'android' => function (string $value, int $i, array $tokens) : array { |
|
| 59 | + 'android' => function(string $value, int $i, array $tokens) : array { |
|
| 60 | 60 | $os = \explode(' ', $value, 3); |
| 61 | 61 | |
| 62 | 62 | // skip language |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | 'bits' => 32, |
| 97 | 97 | ]), |
| 98 | 98 | 'Windows NT ' => new props('any', $fn['platformwindows']), |
| 99 | - 'Windows Phone' => new props('start', function (string $value) : array { |
|
| 99 | + 'Windows Phone' => new props('start', function(string $value) : array { |
|
| 100 | 100 | $version = \mb_substr($value, 14); |
| 101 | 101 | return [ |
| 102 | 102 | 'type' => 'human', |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | 'kernel' => \intval($version) >= 8 ? 'Windows NT' : 'Windows CE' |
| 107 | 107 | ]; |
| 108 | 108 | }), |
| 109 | - 'Win98' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 109 | + 'Win98' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 110 | 110 | foreach ($tokens AS $item) { |
| 111 | 111 | if (\str_starts_with($item, 'PalmSource')) { |
| 112 | 112 | return []; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | 'platform' => 'Windows', |
| 145 | 145 | 'platformversion' => \mb_substr($value, 5) |
| 146 | 146 | ]), |
| 147 | - 'Windows' => new props('any', function (string $value, int $i, array $tokens) use ($fn) : array { |
|
| 147 | + 'Windows' => new props('any', function(string $value, int $i, array $tokens) use ($fn) : array { |
|
| 148 | 148 | foreach ($tokens AS $item) { |
| 149 | 149 | if (\str_starts_with($item, 'PalmSource')) { |
| 150 | 150 | return []; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | 'platformversion' => \mb_substr($value, 6), |
| 161 | 161 | 'bits' => 64 |
| 162 | 162 | ]), |
| 163 | - 'Mac OS X' => new props('any', function (string $value) : array { |
|
| 163 | + 'Mac OS X' => new props('any', function(string $value) : array { |
|
| 164 | 164 | $version = \str_replace('_', '.', \mb_substr($value, \mb_stripos($value, 'Mac OS X') + 9)); |
| 165 | 165 | $register = $version && \intval(\explode('.', $version)[1] ?? 0) >= 6 ? 64 : null; |
| 166 | 166 | return [ |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | 'type' => 'human', |
| 196 | 196 | 'category' => 'mobile', |
| 197 | 197 | 'platform' => 'iOS', |
| 198 | - 'platformversion' => $tokens[$i+1] |
|
| 198 | + 'platformversion' => $tokens[$i + 1] |
|
| 199 | 199 | ]), |
| 200 | - 'CrOS' => new props('start', function (string $value) : array { |
|
| 200 | + 'CrOS' => new props('start', function(string $value) : array { |
|
| 201 | 201 | $parts = \explode(' ', $value); |
| 202 | 202 | return [ |
| 203 | 203 | 'type' => 'human', |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | 'platform' => 'Kindle', |
| 213 | 213 | 'platformversion' => \mb_substr($value, 7) |
| 214 | 214 | ]), |
| 215 | - 'Tizen' => new props('start', function (string $value) : array { |
|
| 215 | + 'Tizen' => new props('start', function(string $value) : array { |
|
| 216 | 216 | $parts = \explode(' ', $value, 2); |
| 217 | 217 | return [ |
| 218 | 218 | 'type' => 'human', |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | 'platformversion' => $parts[1] ?? null |
| 223 | 223 | ]; |
| 224 | 224 | }), |
| 225 | - 'KAIOS/' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 225 | + 'KAIOS/' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 226 | 226 | |
| 227 | 227 | // find device |
| 228 | 228 | foreach ($tokens AS $i => $item) { |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | 'kernel' => 'unix', |
| 296 | 296 | 'platform' => 'Solaris', |
| 297 | 297 | ]), |
| 298 | - 'AmigaOS' => new props('any', function (string $value) : array { |
|
| 298 | + 'AmigaOS' => new props('any', function(string $value) : array { |
|
| 299 | 299 | if (($pos = \mb_stripos($value, 'AmigaOS')) !== false) { |
| 300 | 300 | $value = \mb_substr($value, $pos); |
| 301 | 301 | } |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | 'platformversion' => isset($parts[1]) && \strspn($parts[1], '0123456789.-_') === \strlen($parts[1]) ? $parts[1] : null |
| 309 | 309 | ]; |
| 310 | 310 | }), |
| 311 | - 'Fuchsia' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
| 311 | + 'Fuchsia' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
| 312 | 312 | $os = \explode(' ', $tokens[++$i], 2); |
| 313 | 313 | return [ |
| 314 | 314 | 'type' => 'human', |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | 'platformversion' => isset($os[1]) && \strspn($os[1], '0123456789.-_', \strlen($os[0])) === \strlen($os[1]) ? $os[1] : null |
| 319 | 319 | ]; |
| 320 | 320 | }), |
| 321 | - 'Maemo' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
| 321 | + 'Maemo' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
| 322 | 322 | $os = \explode(' ', $tokens[++$i], 2); |
| 323 | 323 | return [ |
| 324 | 324 | 'type' => 'human', |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | 'kernel' => 'Java VM', |
| 335 | 335 | 'platform' => $value |
| 336 | 336 | ]), |
| 337 | - 'Haiku' => new props('any', function (string $value) : array { |
|
| 337 | + 'Haiku' => new props('any', function(string $value) : array { |
|
| 338 | 338 | $parts = \explode('/', $value, 2); |
| 339 | 339 | return [ |
| 340 | 340 | 'type' => 'human', |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | 'platformversion' => $parts[1] ?? null |
| 345 | 345 | ]; |
| 346 | 346 | }), |
| 347 | - 'BeOS' => new props('start', function (string $value) : array { |
|
| 347 | + 'BeOS' => new props('start', function(string $value) : array { |
|
| 348 | 348 | $parts = \explode('/', $value, 2); |
| 349 | 349 | return [ |
| 350 | 350 | 'type' => 'human', |
@@ -361,14 +361,14 @@ discard block |
||
| 361 | 361 | 'platformversion' => \explode('/', $value, 3)[1] ?: null |
| 362 | 362 | ]), |
| 363 | 363 | 'Android ' => new props('start', $fn['android']), |
| 364 | - 'Linux' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
| 364 | + 'Linux' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
| 365 | 365 | return [ |
| 366 | 366 | 'kernel' => 'Linux', |
| 367 | 367 | 'platform' => 'Linux', |
| 368 | 368 | 'platformversion' => \str_contains($tokens[$i + 1] ?? '', '.') && \strspn($tokens[$i + 1], '0123456789.') >= 3 ? \explode(' ', $tokens[$i + 1])[0] : null |
| 369 | 369 | ]; |
| 370 | 370 | }), |
| 371 | - 'X11' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
| 371 | + 'X11' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
| 372 | 372 | $os = \explode(' ', $tokens[++$i] ?? '', 2); |
| 373 | 373 | return [ |
| 374 | 374 | 'category' => 'desktop', |