@@ -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') !== 0 && !\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', |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | 'Viber/' => new props('start', $fn['appslash']), |
| 130 | 130 | 'Google Web Preview' => new props('start', $fn['appslash']), |
| 131 | 131 | 'MicroMessenger/' => new props('start', $fn['appslash']), |
| 132 | - 'weibo' => new props('any', function (string $value) : array { |
|
| 132 | + 'weibo' => new props('any', function(string $value) : array { |
|
| 133 | 133 | $data = [ |
| 134 | 134 | 'app' => 'Weibo', |
| 135 | 135 | 'appname' => 'Weibo' |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | }), |
| 147 | 147 | |
| 148 | 148 | // special parser for Facebook app because it is completely different to any other |
| 149 | - 'FBAN/' => new props('any', function (string $value) : array { |
|
| 149 | + 'FBAN/' => new props('any', function(string $value) : array { |
|
| 150 | 150 | $map = [ |
| 151 | 151 | 'FBAN/MessengerLiteForiOS' => [ |
| 152 | 152 | 'type' => 'human', |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | 'FBMD/' => new props('start', fn (string $value) : array => [ |
| 202 | 202 | 'model' => \mb_substr($value, 5) |
| 203 | 203 | ]), |
| 204 | - 'FBDM/' => new props('start', function (string $value) : array { |
|
| 204 | + 'FBDM/' => new props('start', function(string $value) : array { |
|
| 205 | 205 | $data = []; |
| 206 | 206 | foreach (\explode(',', \trim(\mb_substr($value, 5), '{}')) AS $item) { |
| 207 | 207 | $parts = \explode('=', $item); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | 'FBSV' => new props('start', fn (string $value) : array => [ |
| 230 | 230 | 'platformversion' => \mb_substr($value, 5) |
| 231 | 231 | ]), |
| 232 | - 'isDarkMode/' => new props('start', function (string $value) : array { |
|
| 232 | + 'isDarkMode/' => new props('start', function(string $value) : array { |
|
| 233 | 233 | $mode = \mb_substr($value, 11); |
| 234 | 234 | return [ |
| 235 | 235 | 'darkmode' => \in_array($mode, ['0', '1'], true) ? \boolval($mode) : null |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | 'NetType/' => new props('start', fn (string $value) : array => [ |
| 242 | 242 | 'nettype' => \mb_convert_case(\mb_substr($value, 8), MB_CASE_UPPER) |
| 243 | 243 | ]), |
| 244 | - 'Microsoft Office' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 244 | + 'Microsoft Office' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 245 | 245 | $data = [ |
| 246 | 246 | 'type' => 'human' |
| 247 | 247 | ]; |
@@ -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 |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | // platforms |
| 80 | 80 | 'Windows NT ' => new props('any', $fn['platformwindows']), |
| 81 | - 'Windows Phone' => new props('start', function (string $value) : array { |
|
| 81 | + 'Windows Phone' => new props('start', function(string $value) : array { |
|
| 82 | 82 | $version = \mb_substr($value, 14); |
| 83 | 83 | return [ |
| 84 | 84 | 'type' => 'human', |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | 'platformversion' => \mb_substr($value, 5) |
| 121 | 121 | ]), |
| 122 | 122 | 'Windows' => new props('any', $fn['platformwindows']), |
| 123 | - 'Mac OS X' => new props('any', function (string $value) : array { |
|
| 123 | + 'Mac OS X' => new props('any', function(string $value) : array { |
|
| 124 | 124 | $version = \str_replace('_', '.', \mb_substr($value, \mb_stripos($value, 'Mac OS X') + 9)); |
| 125 | 125 | $register = $version && \intval(\explode('.', $version)[1] ?? 0) >= 6 ? 64 : null; |
| 126 | 126 | return [ |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | 'platform' => 'iOS', |
| 152 | 152 | 'platformversion' => \str_replace('_', '.', \mb_substr($value, 4)) |
| 153 | 153 | ]), |
| 154 | - 'CrOS' => new props('start', function (string $value) : array { |
|
| 154 | + 'CrOS' => new props('start', function(string $value) : array { |
|
| 155 | 155 | $parts = \explode(' ', $value); |
| 156 | 156 | return [ |
| 157 | 157 | 'type' => 'human', |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | 'platform' => 'Kindle', |
| 167 | 167 | 'platformversion' => \mb_substr($value, 7) |
| 168 | 168 | ]), |
| 169 | - 'Tizen' => new props('start', function (string $value) : array { |
|
| 169 | + 'Tizen' => new props('start', function(string $value) : array { |
|
| 170 | 170 | $parts = \explode(' ', $value, 2); |
| 171 | 171 | return [ |
| 172 | 172 | 'type' => 'human', |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | 'platformversion' => $parts[1] ?? null |
| 177 | 177 | ]; |
| 178 | 178 | }), |
| 179 | - 'KAIOS/' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
| 179 | + 'KAIOS/' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
| 180 | 180 | |
| 181 | 181 | // find device |
| 182 | 182 | foreach ($tokens AS $i => $item) { |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | 'kernel' => 'unix', |
| 250 | 250 | 'platform' => 'Solaris', |
| 251 | 251 | ]), |
| 252 | - 'AmigaOS' => new props('any', function (string $value) : array { |
|
| 252 | + 'AmigaOS' => new props('any', function(string $value) : array { |
|
| 253 | 253 | if (($pos = \mb_stripos($value, 'AmigaOS')) !== false) { |
| 254 | 254 | $value = \mb_substr($value, $pos); |
| 255 | 255 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | 'platformversion' => isset($parts[1]) && \strspn($parts[1], '0123456789.-_') === \strlen($parts[1]) ? $parts[1] : null |
| 263 | 263 | ]; |
| 264 | 264 | }), |
| 265 | - 'Fuchsia' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
| 265 | + 'Fuchsia' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
| 266 | 266 | $os = \explode(' ', $tokens[++$i], 2); |
| 267 | 267 | return [ |
| 268 | 268 | 'type' => 'human', |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | 'platformversion' => isset($os[1]) && \strspn($os[1], '0123456789.-_', \strlen($os[0])) === \strlen($os[1]) ? $os[1] : null |
| 273 | 273 | ]; |
| 274 | 274 | }), |
| 275 | - 'Maemo' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
| 275 | + 'Maemo' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
| 276 | 276 | $os = \explode(' ', $tokens[++$i], 2); |
| 277 | 277 | return [ |
| 278 | 278 | 'type' => 'human', |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | 'kernel' => 'Java VM', |
| 289 | 289 | 'platform' => $value |
| 290 | 290 | ]), |
| 291 | - 'Haiku' => new props('any', function (string $value) : array { |
|
| 291 | + 'Haiku' => new props('any', function(string $value) : array { |
|
| 292 | 292 | $parts = \explode('/', $value, 2); |
| 293 | 293 | return [ |
| 294 | 294 | 'type' => 'human', |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | 'platformversion' => $parts[1] ?? null |
| 299 | 299 | ]; |
| 300 | 300 | }), |
| 301 | - 'BeOS' => new props('start', function (string $value) : array { |
|
| 301 | + 'BeOS' => new props('start', function(string $value) : array { |
|
| 302 | 302 | $parts = \explode('/', $value, 2); |
| 303 | 303 | return [ |
| 304 | 304 | 'type' => 'human', |
@@ -310,14 +310,14 @@ discard block |
||
| 310 | 310 | }), |
| 311 | 311 | 'Android' => new props('exact', $fn['android']), |
| 312 | 312 | 'Android ' => new props('start', $fn['android']), |
| 313 | - 'Linux' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
| 313 | + 'Linux' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
| 314 | 314 | return [ |
| 315 | 315 | 'kernel' => 'Linux', |
| 316 | 316 | 'platform' => 'Linux', |
| 317 | 317 | 'platformversion' => \str_contains($tokens[$i + 1] ?? '', '.') && \strspn($tokens[$i + 1], '0123456789.') >= 3 ? \explode(' ', $tokens[$i + 1])[0] : null |
| 318 | 318 | ]; |
| 319 | 319 | }), |
| 320 | - 'X11' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
| 320 | + 'X11' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
| 321 | 321 | $os = \explode(' ', $tokens[++$i] ?? '', 2); |
| 322 | 322 | return [ |
| 323 | 323 | 'category' => 'desktop', |