@@ -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 []; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | return $fn['platformwindows']($value); |
| 154 | 154 | }), |
| 155 | - 'Mac OS X' => new props('any', function (string $value) : array { |
|
| 155 | + 'Mac OS X' => new props('any', function(string $value) : array { |
|
| 156 | 156 | $version = \str_replace('_', '.', \mb_substr($value, \mb_stripos($value, 'Mac OS X') + 9)); |
| 157 | 157 | $register = $version && \intval(\explode('.', $version)[1] ?? 0) >= 6 ? 64 : null; |
| 158 | 158 | return [ |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | 'platform' => 'iOS', |
| 184 | 184 | 'platformversion' => \str_replace('_', '.', \mb_substr($value, 4)) |
| 185 | 185 | ]), |
| 186 | - 'CrOS' => new props('start', function (string $value) : array { |
|
| 186 | + 'CrOS' => new props('start', function(string $value) : array { |
|
| 187 | 187 | $parts = \explode(' ', $value); |
| 188 | 188 | return [ |
| 189 | 189 | 'type' => 'human', |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | 'platform' => 'Kindle', |
| 199 | 199 | 'platformversion' => \mb_substr($value, 7) |
| 200 | 200 | ]), |
| 201 | - 'Tizen' => new props('start', function (string $value) : array { |
|
| 201 | + 'Tizen' => new props('start', function(string $value) : array { |
|
| 202 | 202 | $parts = \explode(' ', $value, 2); |
| 203 | 203 | return [ |
| 204 | 204 | 'type' => 'human', |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | 'platformversion' => $parts[1] ?? null |
| 209 | 209 | ]; |
| 210 | 210 | }), |
| 211 | - 'KAIOS/' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 211 | + 'KAIOS/' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 212 | 212 | |
| 213 | 213 | // find device |
| 214 | 214 | foreach ($tokens AS $i => $item) { |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | 'kernel' => 'unix', |
| 282 | 282 | 'platform' => 'Solaris', |
| 283 | 283 | ]), |
| 284 | - 'AmigaOS' => new props('any', function (string $value) : array { |
|
| 284 | + 'AmigaOS' => new props('any', function(string $value) : array { |
|
| 285 | 285 | if (($pos = \mb_stripos($value, 'AmigaOS')) !== false) { |
| 286 | 286 | $value = \mb_substr($value, $pos); |
| 287 | 287 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | 'platformversion' => isset($parts[1]) && \strspn($parts[1], '0123456789.-_') === \strlen($parts[1]) ? $parts[1] : null |
| 295 | 295 | ]; |
| 296 | 296 | }), |
| 297 | - 'Fuchsia' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
| 297 | + 'Fuchsia' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
| 298 | 298 | $os = \explode(' ', $tokens[++$i], 2); |
| 299 | 299 | return [ |
| 300 | 300 | 'type' => 'human', |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | 'platformversion' => isset($os[1]) && \strspn($os[1], '0123456789.-_', \strlen($os[0])) === \strlen($os[1]) ? $os[1] : null |
| 305 | 305 | ]; |
| 306 | 306 | }), |
| 307 | - 'Maemo' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
| 307 | + 'Maemo' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
| 308 | 308 | $os = \explode(' ', $tokens[++$i], 2); |
| 309 | 309 | return [ |
| 310 | 310 | 'type' => 'human', |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | 'kernel' => 'Java VM', |
| 321 | 321 | 'platform' => $value |
| 322 | 322 | ]), |
| 323 | - 'Haiku' => new props('any', function (string $value) : array { |
|
| 323 | + 'Haiku' => new props('any', function(string $value) : array { |
|
| 324 | 324 | $parts = \explode('/', $value, 2); |
| 325 | 325 | return [ |
| 326 | 326 | 'type' => 'human', |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | 'platformversion' => $parts[1] ?? null |
| 331 | 331 | ]; |
| 332 | 332 | }), |
| 333 | - 'BeOS' => new props('start', function (string $value) : array { |
|
| 333 | + 'BeOS' => new props('start', function(string $value) : array { |
|
| 334 | 334 | $parts = \explode('/', $value, 2); |
| 335 | 335 | return [ |
| 336 | 336 | 'type' => 'human', |
@@ -342,14 +342,14 @@ discard block |
||
| 342 | 342 | }), |
| 343 | 343 | 'Android' => new props('exact', $fn['android']), |
| 344 | 344 | 'Android ' => new props('start', $fn['android']), |
| 345 | - 'Linux' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
| 345 | + 'Linux' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
| 346 | 346 | return [ |
| 347 | 347 | 'kernel' => 'Linux', |
| 348 | 348 | 'platform' => 'Linux', |
| 349 | 349 | 'platformversion' => \str_contains($tokens[$i + 1] ?? '', '.') && \strspn($tokens[$i + 1], '0123456789.') >= 3 ? \explode(' ', $tokens[$i + 1])[0] : null |
| 350 | 350 | ]; |
| 351 | 351 | }), |
| 352 | - 'X11' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
| 352 | + 'X11' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
| 353 | 353 | $os = \explode(' ', $tokens[++$i] ?? '', 2); |
| 354 | 354 | return [ |
| 355 | 355 | 'category' => 'desktop', |
@@ -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', |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | 'app' => 'WeChat', |
| 136 | 136 | 'appname' => 'MicroMessenger' |
| 137 | 137 | ]), |
| 138 | - 'weibo' => new props('any', function (string $value) : array { |
|
| 138 | + 'weibo' => new props('any', function(string $value) : array { |
|
| 139 | 139 | $data = [ |
| 140 | 140 | 'app' => 'Weibo', |
| 141 | 141 | 'appname' => 'Weibo' |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | }), |
| 153 | 153 | |
| 154 | 154 | // special parser for Facebook app because it is completely different to any other |
| 155 | - 'FBAN/' => new props('any', function (string $value) : array { |
|
| 155 | + 'FBAN/' => new props('any', function(string $value) : array { |
|
| 156 | 156 | $map = [ |
| 157 | 157 | 'FBAN/MessengerLiteForiOS' => [ |
| 158 | 158 | 'type' => 'human', |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | 'FBMD/' => new props('start', fn (string $value) : array => [ |
| 208 | 208 | 'model' => \mb_substr($value, 5) |
| 209 | 209 | ]), |
| 210 | - 'FBDM/' => new props('start', function (string $value) : array { |
|
| 210 | + 'FBDM/' => new props('start', function(string $value) : array { |
|
| 211 | 211 | $data = []; |
| 212 | 212 | foreach (\explode(',', \trim(\mb_substr($value, 5), '{}')) AS $item) { |
| 213 | 213 | $parts = \explode('=', $item); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | 'FBSV' => new props('start', fn (string $value) : array => [ |
| 236 | 236 | 'platformversion' => \mb_substr($value, 5) |
| 237 | 237 | ]), |
| 238 | - 'isDarkMode/' => new props('start', function (string $value) : array { |
|
| 238 | + 'isDarkMode/' => new props('start', function(string $value) : array { |
|
| 239 | 239 | $mode = \mb_substr($value, 11); |
| 240 | 240 | return [ |
| 241 | 241 | 'darkmode' => \in_array($mode, ['0', '1'], true) ? \boolval($mode) : null |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | 'NetType/' => new props('start', fn (string $value) : array => [ |
| 248 | 248 | 'nettype' => \mb_convert_case(\mb_substr($value, 8), MB_CASE_UPPER) |
| 249 | 249 | ]), |
| 250 | - 'Microsoft Office' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 250 | + 'Microsoft Office' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 251 | 251 | $data = [ |
| 252 | 252 | 'type' => 'human' |
| 253 | 253 | ]; |