@@ -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.'); |
@@ -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 config { |
@@ -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 [ |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'platform' => 'iOS', |
146 | 146 | 'platformversion' => \mb_substr($value, 4) |
147 | 147 | ]), |
148 | - 'CrOS' => new props('start', function (string $value) : array { |
|
148 | + 'CrOS' => new props('start', function(string $value) : array { |
|
149 | 149 | $parts = \explode(' ', $value); |
150 | 150 | return [ |
151 | 151 | 'type' => 'human', |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | 'platform' => 'Kindle', |
161 | 161 | 'platformversion' => \mb_substr($value, 7) |
162 | 162 | ]), |
163 | - 'Tizen' => new props('start', function (string $value) : array { |
|
163 | + 'Tizen' => new props('start', function(string $value) : array { |
|
164 | 164 | $parts = \explode(' ', $value, 2); |
165 | 165 | return [ |
166 | 166 | 'type' => 'human', |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | 'platformversion' => $parts[1] ?? null |
171 | 171 | ]; |
172 | 172 | }), |
173 | - 'KAIOS/' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
173 | + 'KAIOS/' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
174 | 174 | |
175 | 175 | // find device |
176 | 176 | foreach ($tokens AS $i => $item) { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | 'kernel' => 'unix', |
244 | 244 | 'platform' => 'Solaris', |
245 | 245 | ]), |
246 | - 'AmigaOS' => new props('any', function (string $value) : array { |
|
246 | + 'AmigaOS' => new props('any', function(string $value) : array { |
|
247 | 247 | if (($pos = \mb_stripos($value, 'AmigaOS')) !== false) { |
248 | 248 | $value = \mb_substr($value, $pos); |
249 | 249 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'platformversion' => isset($parts[1]) && \strspn($parts[1], '0123456789.-_') === \strlen($parts[1]) ? $parts[1] : null |
257 | 257 | ]; |
258 | 258 | }), |
259 | - 'Fuchsia' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
259 | + 'Fuchsia' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
260 | 260 | $os = \explode(' ', $tokens[++$i], 2); |
261 | 261 | return [ |
262 | 262 | 'type' => 'human', |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | 'platformversion' => isset($os[1]) && \strspn($os[1], '0123456789.-_', \strlen($os[0])) === \strlen($os[1]) ? $os[1] : null |
267 | 267 | ]; |
268 | 268 | }), |
269 | - 'Maemo' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
269 | + 'Maemo' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
270 | 270 | $os = \explode(' ', $tokens[++$i], 2); |
271 | 271 | return [ |
272 | 272 | 'type' => 'human', |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | 'kernel' => 'Java VM', |
283 | 283 | 'platform' => $value |
284 | 284 | ]), |
285 | - 'Haiku' => new props('any', function (string $value) : array { |
|
285 | + 'Haiku' => new props('any', function(string $value) : array { |
|
286 | 286 | $parts = \explode('/', $value, 2); |
287 | 287 | return [ |
288 | 288 | 'type' => 'human', |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | 'platformversion' => $parts[1] ?? null |
293 | 293 | ]; |
294 | 294 | }), |
295 | - 'BeOS' => new props('start', function (string $value) : array { |
|
295 | + 'BeOS' => new props('start', function(string $value) : array { |
|
296 | 296 | $parts = \explode('/', $value, 2); |
297 | 297 | return [ |
298 | 298 | 'type' => 'human', |
@@ -304,14 +304,14 @@ discard block |
||
304 | 304 | }), |
305 | 305 | 'Android' => new props('exact', $fn['android']), |
306 | 306 | 'Android ' => new props('start', $fn['android']), |
307 | - 'Linux' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
307 | + 'Linux' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
308 | 308 | return [ |
309 | 309 | 'kernel' => 'Linux', |
310 | 310 | 'platform' => 'Linux', |
311 | 311 | 'platformversion' => \str_contains($tokens[$i + 1] ?? '', '.') && \strspn($tokens[$i + 1], '0123456789.') >= 3 ? \explode(' ', $tokens[$i + 1])[0] : null |
312 | 312 | ]; |
313 | 313 | }), |
314 | - 'X11' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
314 | + 'X11' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
315 | 315 | $os = \explode(' ', $tokens[++$i] ?? '', 2); |
316 | 316 | return [ |
317 | 317 | '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 categories { |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | 'type' => 'human', |
20 | 20 | 'category' => 'mobile' |
21 | 21 | ]), |
22 | - 'Moblie' => new props('exact', [ // some samsung devices mispelt it |
|
22 | + 'Moblie' => new props('exact', [// some samsung devices mispelt it |
|
23 | 23 | 'type' => 'human', |
24 | 24 | 'category' => 'mobile' |
25 | 25 | ]), |
@@ -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; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | return []; |
47 | 47 | }, |
48 | - 'langslash' => function (string $value) : array { |
|
48 | + 'langslash' => function(string $value) : array { |
|
49 | 49 | $parts = \explode('-', \str_replace('_', '-', \explode('/', $value, 2)[1]), 4); |
50 | 50 | $suffix = $parts[2] ?? $parts[1] ?? null; |
51 | 51 | return [ |
@@ -54,20 +54,20 @@ discard block |
||
54 | 54 | } |
55 | 55 | ]; |
56 | 56 | return [ |
57 | - 'com.google.GoogleMobile/' => new props('start', function (string $value, int $i, array $tokens, string $match) use ($fn) : array { |
|
57 | + 'com.google.GoogleMobile/' => new props('start', function(string $value, int $i, array $tokens, string $match) use ($fn) : array { |
|
58 | 58 | return \array_merge($fn['appslash']($value, $i, $tokens, $match), [ |
59 | 59 | 'category' => 'mobile' |
60 | 60 | ]); |
61 | 61 | }), |
62 | 62 | 'com.google.' => new props('start', $fn['appslash']), |
63 | - 'OcIdWebView' => new props('exact', function (string $value) : array { |
|
63 | + 'OcIdWebView' => new props('exact', function(string $value) : array { |
|
64 | 64 | $data = [ |
65 | 65 | 'app' => 'Google App Web View', |
66 | 66 | 'appname' => $value |
67 | 67 | ]; |
68 | 68 | return $data; |
69 | 69 | }), |
70 | - 'Instagram' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
70 | + 'Instagram' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
71 | 71 | $parts = \explode(' ', $value, 4); |
72 | 72 | $data = [ |
73 | 73 | 'type' => 'human', |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'AppleExchangeWebServices/' => new props('start', $fn['appslash']), |
162 | 162 | |
163 | 163 | // special parser for Facebook app because it is completely different to any other |
164 | - 'FBAN/' => new props('any', function (string $value) : array { |
|
164 | + 'FBAN/' => new props('any', function(string $value) : array { |
|
165 | 165 | $map = [ |
166 | 166 | 'FBAN/MessengerLiteForiOS' => [ |
167 | 167 | 'type' => 'human', |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | 'model' => \mb_substr($value, 5) |
218 | 218 | ]), |
219 | 219 | 'FBLC/' => new props('start', $fn['langslash']), |
220 | - 'FBDM/' => new props('start', function (string $value) : array { |
|
220 | + 'FBDM/' => new props('start', function(string $value) : array { |
|
221 | 221 | $data = []; |
222 | 222 | foreach (\explode(',', \trim(\mb_substr($value, 5), '{}')) AS $item) { |
223 | 223 | $parts = \explode('=', $item); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'FBSV' => new props('start', fn (string $value) : array => [ |
246 | 246 | 'platformversion' => \mb_substr($value, 5) |
247 | 247 | ]), |
248 | - 'isDarkMode/' => new props('start', function (string $value) : array { |
|
248 | + 'isDarkMode/' => new props('start', function(string $value) : array { |
|
249 | 249 | $mode = \mb_substr($value, 11); |
250 | 250 | return [ |
251 | 251 | 'darkmode' => \in_array($mode, ['0', '1'], true) ? \boolval($mode) : null |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | 'NetType/' => new props('start', fn (string $value) : array => [ |
256 | 256 | 'nettype' => \mb_convert_case(\mb_substr($value, 8), MB_CASE_UPPER) |
257 | 257 | ]), |
258 | - 'Microsoft Office' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
258 | + 'Microsoft Office' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
259 | 259 | $data = [ |
260 | 260 | 'type' => 'human' |
261 | 261 | ]; |