@@ -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]) && !\is_numeric($parts[1]) ? 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 => [ |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | 'Instapaper' => new props('start', fn (string $value, int $i, array $tokens, string $match) => \array_merge([ |
188 | 188 | 'type' => 'human' |
189 | 189 | ], $fn['appslash']($value, $i, $tokens, $match))), |
190 | - 'Player/LG' => new props('start', function (string $value, int $i, array $tokens) : ?array { |
|
191 | - if (\str_starts_with($tokens[$i+1], 'Player ')) { |
|
192 | - $parts = \explode(' ', $tokens[$i+1]); |
|
190 | + 'Player/LG' => new props('start', function(string $value, int $i, array $tokens) : ?array { |
|
191 | + if (\str_starts_with($tokens[$i + 1], 'Player ')) { |
|
192 | + $parts = \explode(' ', $tokens[$i + 1]); |
|
193 | 193 | $device = $i === 1 ? \explode('/', $tokens[0]) : null; |
194 | 194 | return [ |
195 | 195 | 'type' => 'human', |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | 'app' => 'WeChat', |
219 | 219 | 'appname' => 'MicroMessenger' |
220 | 220 | ]), |
221 | - 'weibo' => new props('any', function (string $value) : array { |
|
221 | + 'weibo' => new props('any', function(string $value) : array { |
|
222 | 222 | $data = [ |
223 | 223 | 'app' => 'Weibo', |
224 | 224 | 'appname' => 'Weibo' |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | }), |
236 | 236 | |
237 | 237 | // special parser for Facebook app because it is completely different to any other |
238 | - 'FBAN/' => new props('any', function (string $value) : array { |
|
238 | + 'FBAN/' => new props('any', function(string $value) : array { |
|
239 | 239 | $map = [ |
240 | 240 | 'FBAN/MessengerLiteForiOS' => [ |
241 | 241 | 'type' => 'human', |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | 'FBMD/' => new props('start', fn (string $value) : array => [ |
291 | 291 | 'model' => \mb_substr($value, 5) |
292 | 292 | ]), |
293 | - 'FBDM/' => new props('start', function (string $value) : array { |
|
293 | + 'FBDM/' => new props('start', function(string $value) : array { |
|
294 | 294 | $data = []; |
295 | 295 | foreach (\explode(',', \trim(\mb_substr($value, 5), '{}')) AS $item) { |
296 | 296 | $parts = \explode('=', $item); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | 'FBSV' => new props('start', fn (string $value) : array => [ |
319 | 319 | 'platformversion' => \mb_substr($value, 5) |
320 | 320 | ]), |
321 | - 'isDarkMode/' => new props('start', function (string $value) : array { |
|
321 | + 'isDarkMode/' => new props('start', function(string $value) : array { |
|
322 | 322 | $mode = \mb_substr($value, 11); |
323 | 323 | return [ |
324 | 324 | 'darkmode' => \in_array($mode, ['0', '1'], true) ? \boolval($mode) : null |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | 'NetType/' => new props('start', fn (string $value) : array => [ |
331 | 331 | 'nettype' => \mb_convert_case(\mb_substr($value, 8), MB_CASE_UPPER) |
332 | 332 | ]), |
333 | - 'Microsoft Office' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
333 | + 'Microsoft Office' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
334 | 334 | $data = [ |
335 | 335 | 'type' => 'human' |
336 | 336 | ]; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | }), |
365 | 365 | |
366 | 366 | // TikTok |
367 | - 'AppName/' => new props('start', function (string $value) : array { |
|
367 | + 'AppName/' => new props('start', function(string $value) : array { |
|
368 | 368 | $map = [ |
369 | 369 | 'AppName/musical_ly' => 'TikTok', |
370 | 370 | 'AppName/aweme' => 'Douyin' |