@@ -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 browsers { |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | public static function get() : array { |
68 | 68 | $fn = [ |
69 | 69 | 'browserslash' => fn (string $value, int $i, array $tokens, string $key, array $config = []) : array => self::getBrowser($value, $i, $tokens, $key, $config), |
70 | - 'gecko' => function (string $value, int $i, array $tokens, string $key, array $config = []) : array { |
|
70 | + 'gecko' => function(string $value, int $i, array $tokens, string $key, array $config = []) : array { |
|
71 | 71 | $parts = \explode('/', $value, 2); |
72 | 72 | return \array_replace(self::getBrowser($value, $i, $tokens, $key, $config), [ |
73 | 73 | 'engine' => 'Gecko', |
74 | 74 | 'engineversion' => $parts[1] ?? null, |
75 | 75 | ]); |
76 | 76 | }, |
77 | - 'presto' => function (string $value, int $i, array $tokens, string $key, array $config = []) : array { |
|
77 | + 'presto' => function(string $value, int $i, array $tokens, string $key, array $config = []) : array { |
|
78 | 78 | $parts = \explode('/', $value, 2); |
79 | 79 | return \array_replace(self::getBrowser($value, $i, $tokens, $key, $config), [ |
80 | 80 | 'engine' => 'Presto', |
81 | 81 | 'engineversion' => $parts[1] ?? null, |
82 | 82 | ]); |
83 | 83 | }, |
84 | - 'chromium' => function (string $value, int $i, array $tokens, string $key, array $config = []) : array { |
|
84 | + 'chromium' => function(string $value, int $i, array $tokens, string $key, array $config = []) : array { |
|
85 | 85 | $parts = \explode('/', $value, 3); |
86 | 86 | $engineversion = isset($parts[1]) && \strspn($parts[1], '1234567890.') === \strlen($parts[1]) ? $parts[1] : null; |
87 | 87 | return \array_replace(self::getBrowser($value, $i, $tokens, $key, $config), [ |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | 'engineversion' => $engineversion |
90 | 90 | ]); |
91 | 91 | }, |
92 | - 'safari' => function (string $value, int $i, array $tokens, string $key, array $config = []) : array { |
|
92 | + 'safari' => function(string $value, int $i, array $tokens, string $key, array $config = []) : array { |
|
93 | 93 | $parts = \explode('/', $value, 2); |
94 | 94 | $version = $parts[1] ?? null; |
95 | 95 | foreach ($tokens AS $item) { |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | 'Obigo/' => new props('start', $fn['browserslash']), |
149 | 149 | 'VivoBrowser/' => new props('start', $fn['browserslash']), |
150 | 150 | 'com.vivo.browser/' => new props('any', $fn['browserslash']), |
151 | - 'QQBrowser/' => new props('any', function (string $value, int $i, array $tokens, string $key, array $config = []) use ($fn) : array { |
|
151 | + 'QQBrowser/' => new props('any', function(string $value, int $i, array $tokens, string $key, array $config = []) use ($fn) : array { |
|
152 | 152 | return $fn['browserslash'](\mb_substr($value, \mb_stripos($value, 'QQBrowser/') ?: 0), $i, $tokens, $key, $config); // sometimes missing a space from previous declaration, and MQQBrowser for mobile. |
153 | 153 | }), |
154 | - 'MiuiBrowser/' => new props('any', function (string $value, int $i, array $tokens, string $key, array $config = []) use ($fn) : array { |
|
154 | + 'MiuiBrowser/' => new props('any', function(string $value, int $i, array $tokens, string $key, array $config = []) use ($fn) : array { |
|
155 | 155 | return $fn['browserslash'](\mb_substr($value, \mb_stripos($value, 'MiuiBrowser/') ?: 0), $i, $tokens, $key, $config); |
156 | 156 | }), |
157 | 157 | 'Lynx/' => new props('start', fn (string $value) : array => [ |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'type' => 'human', |
162 | 162 | 'category' => 'desktop' |
163 | 163 | ]), |
164 | - 'Midori' => new props('start', function (string $value, int $i, array $tokens, string $key, array $config = []) : array { |
|
164 | + 'Midori' => new props('start', function(string $value, int $i, array $tokens, string $key, array $config = []) : array { |
|
165 | 165 | $parts = \explode('/', $value, 2); |
166 | 166 | $version = $parts[1] ?? \explode(' ', $value, 2)[1] ?? null; |
167 | 167 | $major = $version !== null ? \intval($version) : null; |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | 'engine' => 'Gecko', |
182 | 182 | 'browser' => 'Firefox' |
183 | 183 | ]), |
184 | - 'Minimo/' => new props('start', function (string $value, int $i, array $tokens, string $key, array $config = []) use ($fn) : array { |
|
184 | + 'Minimo/' => new props('start', function(string $value, int $i, array $tokens, string $key, array $config = []) use ($fn) : array { |
|
185 | 185 | $data = $fn['browserslash']($value, $i, $tokens, $key, $config); |
186 | 186 | return \array_merge($data, [ |
187 | 187 | 'engine' => 'Gecko' |
188 | 188 | ]); |
189 | 189 | }), |
190 | - 'BonEcho/' => new props('start', function (string $value, int $i, array $tokens, string $key, array $config = []) use ($fn) : array { |
|
190 | + 'BonEcho/' => new props('start', function(string $value, int $i, array $tokens, string $key, array $config = []) use ($fn) : array { |
|
191 | 191 | $data = $fn['browserslash']($value, $i, $tokens, $key, $config); |
192 | 192 | return \array_merge($data, [ |
193 | 193 | 'engine' => 'Gecko' |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | 'browserversion' => \mb_substr($value, 9), |
234 | 234 | 'engine' => 'Trident' |
235 | 235 | ], versions::get('ie', \mb_substr($value, 9), $config['versions']))), |
236 | - 'Trident' => new props('start', [ // infill for missing browser name |
|
236 | + 'Trident' => new props('start', [// infill for missing browser name |
|
237 | 237 | 'browser' => 'Internet Explorer' |
238 | 238 | ]), |
239 | 239 | 'Cronet/' => new props('start', $fn['chromium']), |
@@ -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, '://') && !\str_starts_with($value, 'appid/')) { |
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', |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | 'app' => 'WeChat', |
224 | 224 | 'appname' => 'MicroMessenger' |
225 | 225 | ]), |
226 | - 'weibo' => new props('any', function (string $value) : array { |
|
226 | + 'weibo' => new props('any', function(string $value) : array { |
|
227 | 227 | $data = [ |
228 | 228 | 'type' => 'human', |
229 | 229 | 'app' => 'Weibo', |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | }), |
252 | 252 | |
253 | 253 | // special parser for Facebook app because it is completely different to any other |
254 | - 'FBAN/' => new props('any', function (string $value) : array { |
|
254 | + 'FBAN/' => new props('any', function(string $value) : array { |
|
255 | 255 | $map = [ |
256 | 256 | 'FBAN/MessengerLiteForiOS' => [ |
257 | 257 | 'type' => 'human', |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | 'appname' => 'Facebook', |
335 | 335 | 'model' => \mb_substr($value, 5) |
336 | 336 | ]), |
337 | - 'FBDM/' => new props('start', function (string $value) : array { |
|
337 | + 'FBDM/' => new props('start', function(string $value) : array { |
|
338 | 338 | $data = [ |
339 | 339 | 'type' => 'human', |
340 | 340 | 'app' => 'Facebook', |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | 'appname' => 'Facebook', |
364 | 364 | 'platformversion' => \mb_substr($value, 5) |
365 | 365 | ]), |
366 | - 'isDarkMode/' => new props('start', function (string $value) : array { |
|
366 | + 'isDarkMode/' => new props('start', function(string $value) : array { |
|
367 | 367 | $mode = \mb_substr($value, 11); |
368 | 368 | return [ |
369 | 369 | 'darkmode' => \in_array($mode, ['0', '1'], true) ? \boolval($mode) : null |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | 'AppTheme/' => new props('start', fn (string $value) : array => [ |
374 | 374 | 'darkmode' => \mb_substr($value, 9) === 'dark' |
375 | 375 | ]), |
376 | - 'Microsoft Office' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
376 | + 'Microsoft Office' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
377 | 377 | $data = [ |
378 | 378 | 'type' => 'human' |
379 | 379 | ]; |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | }), |
408 | 408 | |
409 | 409 | // TikTok |
410 | - 'AppName/' => new props('start', function (string $value) : array { |
|
410 | + 'AppName/' => new props('start', function(string $value) : array { |
|
411 | 411 | $map = [ |
412 | 412 | 'AppName/musical_ly' => 'TikTok', |
413 | 413 | 'AppName/aweme' => 'Douyin' |
@@ -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', |
@@ -376,13 +376,13 @@ discard block |
||
376 | 376 | 'dpi=' => new props('start', fn (string $value) : array => [ |
377 | 377 | 'dpi' => \mb_substr($value, 4) |
378 | 378 | ]), |
379 | - 'NetType/' => new props('start', function (string $value) : array { |
|
379 | + 'NetType/' => new props('start', function(string $value) : array { |
|
380 | 380 | $type = \mb_convert_case(\mb_substr($value, 8), MB_CASE_UPPER); |
381 | 381 | return [ |
382 | 382 | 'nettype' => \in_array($type, ['WF', 'WIFI'], true) ? 'WiFi' : $type |
383 | 383 | ]; |
384 | 384 | }), |
385 | - 'netWorkType/' => new props('start', function (string $value) : array { |
|
385 | + 'netWorkType/' => new props('start', function(string $value) : array { |
|
386 | 386 | $type = \mb_convert_case(\mb_substr($value, 12), MB_CASE_UPPER); |
387 | 387 | return [ |
388 | 388 | 'nettype' => \in_array($type, ['WF', 'WIFI'], true) ? 'WiFi' : $type |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | '4.5G' => new props('exact', ['nettype' => '4g']), |
395 | 395 | '4.5G+' => new props('exact', ['nettype' => '4g']), |
396 | 396 | '5G' => new props('exact', ['nettype' => '5g']), |
397 | - 'x' => new props('any', function (string $value) : ?array { |
|
397 | + 'x' => new props('any', function(string $value) : ?array { |
|
398 | 398 | if (\str_contains($value, '@')) { |
399 | 399 | $dpi = \explode('@', $value); |
400 | 400 | $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,7 +195,7 @@ discard block |
||
195 | 195 | 'type' => 'human', |
196 | 196 | 'category' => 'mobile', |
197 | 197 | 'platform' => 'iOS', |
198 | - 'platformversion' => $tokens[$i+1] ?? null |
|
198 | + 'platformversion' => $tokens[$i + 1] ?? null |
|
199 | 199 | ]), |
200 | 200 | 'iPadOS' => new props('exact', fn (string $value, int $i, array $tokens) : array => [ |
201 | 201 | 'type' => 'human', |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | 'vendor' => 'Apple', |
204 | 204 | 'device' => 'iPad', |
205 | 205 | 'platform' => 'iOS', |
206 | - 'platformversion' => $tokens[$i+1] ?? null |
|
206 | + 'platformversion' => $tokens[$i + 1] ?? null |
|
207 | 207 | ]), |
208 | - 'CrOS' => new props('start', function (string $value) : array { |
|
208 | + 'CrOS' => new props('start', function(string $value) : array { |
|
209 | 209 | $parts = \explode(' ', $value); |
210 | 210 | return [ |
211 | 211 | 'type' => 'human', |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | 'platform' => 'Kindle', |
221 | 221 | 'platformversion' => \mb_substr($value, 7) |
222 | 222 | ]), |
223 | - 'Tizen' => new props('start', function (string $value) : array { |
|
223 | + 'Tizen' => new props('start', function(string $value) : array { |
|
224 | 224 | $parts = \explode(' ', $value, 2); |
225 | 225 | return [ |
226 | 226 | 'type' => 'human', |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | 'platformversion' => $parts[1] ?? null |
231 | 231 | ]; |
232 | 232 | }), |
233 | - 'KAIOS/' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
233 | + 'KAIOS/' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
234 | 234 | |
235 | 235 | // find device |
236 | 236 | foreach ($tokens AS $i => $item) { |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | 'platform' => 'WebOS', |
298 | 298 | 'platformversion' => \mb_substr($value, 5) |
299 | 299 | ]), |
300 | - 'Roku ' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
300 | + 'Roku ' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
301 | 301 | $app = \str_contains($tokens[$i - 1] ?? '', '/') ? \explode('/', $tokens[$i - 1], 2) : null; |
302 | 302 | return \array_merge( |
303 | 303 | [ |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | 'kernel' => 'unix', |
319 | 319 | 'platform' => 'Solaris', |
320 | 320 | ]), |
321 | - 'AmigaOS' => new props('any', function (string $value) : array { |
|
321 | + 'AmigaOS' => new props('any', function(string $value) : array { |
|
322 | 322 | if (($pos = \mb_stripos($value, 'AmigaOS')) !== false) { |
323 | 323 | $value = \mb_substr($value, $pos); |
324 | 324 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | 'platformversion' => isset($parts[1]) && \strspn($parts[1], '0123456789.-_') === \strlen($parts[1]) ? $parts[1] : null |
332 | 332 | ]; |
333 | 333 | }), |
334 | - 'Fuchsia' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
334 | + 'Fuchsia' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
335 | 335 | $os = \explode(' ', $tokens[++$i], 2); |
336 | 336 | return [ |
337 | 337 | 'type' => 'human', |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | 'platformversion' => isset($os[1]) && \strspn($os[1], '0123456789.-_', \strlen($os[0])) === \strlen($os[1]) ? $os[1] : null |
342 | 342 | ]; |
343 | 343 | }), |
344 | - 'Maemo' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
344 | + 'Maemo' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
345 | 345 | $os = \explode(' ', $tokens[++$i], 2); |
346 | 346 | return [ |
347 | 347 | 'type' => 'human', |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | 'kernel' => 'Java VM', |
358 | 358 | 'platform' => $value |
359 | 359 | ]), |
360 | - 'Haiku' => new props('any', function (string $value) : array { |
|
360 | + 'Haiku' => new props('any', function(string $value) : array { |
|
361 | 361 | $parts = \explode('/', $value, 2); |
362 | 362 | return [ |
363 | 363 | 'type' => 'human', |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | 'platformversion' => $parts[1] ?? null |
368 | 368 | ]; |
369 | 369 | }), |
370 | - 'BeOS' => new props('start', function (string $value) : array { |
|
370 | + 'BeOS' => new props('start', function(string $value) : array { |
|
371 | 371 | $parts = \explode('/', $value, 2); |
372 | 372 | return [ |
373 | 373 | 'type' => 'human', |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | ]), |
386 | 386 | 'Android ' => new props('start', $fn['android']), |
387 | 387 | 'Android-' => new props('start', $fn['android']), |
388 | - 'Linux' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
388 | + 'Linux' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
389 | 389 | return [ |
390 | 390 | 'kernel' => 'Linux', |
391 | 391 | 'platform' => 'Linux', |
392 | 392 | 'platformversion' => \str_contains($tokens[$i + 1] ?? '', '.') && \strspn($tokens[$i + 1], '0123456789.') >= 3 ? \explode(' ', $tokens[$i + 1])[0] : null |
393 | 393 | ]; |
394 | 394 | }), |
395 | - 'X11' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
395 | + 'X11' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
396 | 396 | $os = \explode(' ', $tokens[++$i] ?? '', 2); |
397 | 397 | return [ |
398 | 398 | '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 agentzero { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return agentzero|false An agentzero object containing the parsed values of the input UA, or false if it could not be parsed |
196 | 196 | */ |
197 | 197 | public static function parse(string $ua, array $hints = [], array $config = []) : agentzero|false { |
198 | - $ua = \str_replace(' ', ' ', \trim(\preg_replace( '/[^[:print:]]/', '', $ua))); |
|
198 | + $ua = \str_replace(' ', ' ', \trim(\preg_replace('/[^[:print:]]/', '', $ua))); |
|
199 | 199 | |
200 | 200 | // parse client hints |
201 | 201 | $hinted = $ua; |