@@ -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 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | 'ads' => fn (string $value) : array => self::getApp($value, ['category' => 'ads']), |
44 | 44 | 'validator' => fn (string $value) : array => self::getApp($value, ['category' => 'validator']), |
45 | 45 | 'feed' => fn (string $value) : array => self::getApp($value, ['category' => 'feed']), |
46 | - 'crawler' => function (string $value) : array { |
|
46 | + 'crawler' => function(string $value) : array { |
|
47 | 47 | $parts = \explode('/', $value, 2); |
48 | 48 | $map = [ |
49 | 49 | 'baiduspider' => 'search', |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | }, |
60 | 60 | 'monitor' => fn (string $value) : array => self::getApp($value, ['category' => 'monitor']), |
61 | 61 | 'scraper' => fn (string $value) : array => self::getApp($value, ['category' => 'scraper']), |
62 | - 'map' => function (string $value) : ?array { |
|
62 | + 'map' => function(string $value) : ?array { |
|
63 | 63 | if (!\str_contains($value, '://') && \strcasecmp('Cubot', $value) !== 0 && \strcasecmp('Power bot', $value) !== 0) { // bot will be in the URL |
64 | 64 | $parts = \explode('/', $value, 2); |
65 | 65 | $category = [ |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'Uptime/' => new props('start', $fn['monitor']), |
146 | 146 | 'HostTracker/' => new props('start', $fn['monitor']), |
147 | 147 | 'NCSC Web Check [email protected]' => new props('exact', $fn['monitor']), |
148 | - 'Pingdom.com' => new props('start', function (string $value) : array { |
|
148 | + 'Pingdom.com' => new props('start', function(string $value) : array { |
|
149 | 149 | $version = \explode('_', \trim($value, '_')); |
150 | 150 | return [ |
151 | 151 | 'type' => 'robot', |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | 'Rogerbot/' => new props('start', $fn['crawler']), |
177 | 177 | 'Go-http-client/' => new props('start', $fn['scraper']), |
178 | 178 | 'DashLinkPreviews/' => new props('start', $fn['feed']), |
179 | - 'Microsoft Office' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
179 | + 'Microsoft Office' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
180 | 180 | $data = [ |
181 | 181 | 'type' => 'human' |
182 | 182 | ]; |
@@ -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 | /** |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @return props An array with keys representing the string to match, and a value of an array containing parsing and output settings |
14 | 14 | */ |
15 | 15 | public static function get() : array { |
16 | - $fn = function (string $value, int $i, array $tokens) : ?array { |
|
16 | + $fn = function(string $value, int $i, array $tokens) : ?array { |
|
17 | 17 | if (($start = \stripos($value, 'http://')) === false) { |
18 | 18 | if (($start = \stripos($value, 'https://')) === false) { |
19 | 19 | $start = \stripos($value, 'www.'); |
@@ -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 | /** |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public static function get() : array { |
16 | 16 | $fn = [ |
17 | - 'appslash' => function (string $value, int $i, array $tokens, string $match) : array { |
|
17 | + 'appslash' => function(string $value, int $i, array $tokens, string $match) : array { |
|
18 | 18 | if (\mb_stripos($value, 'AppleWebKit') !== 0 && !\str_contains($value, '://')) { |
19 | 19 | $parts = \explode('/', $value, 4); |
20 | 20 | $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,19 +54,19 @@ discard block |
||
54 | 54 | } |
55 | 55 | ]; |
56 | 56 | return [ |
57 | - 'OcIdWebView' => new props('exact', function (string $value) : array { |
|
57 | + 'OcIdWebView' => new props('exact', function(string $value) : array { |
|
58 | 58 | $data = [ |
59 | 59 | 'app' => $value |
60 | 60 | ]; |
61 | 61 | return $data; |
62 | 62 | }), |
63 | - 'com.google.GoogleMobile/' => new props('start', function (string $value, int $i, array $tokens, string $match) use ($fn) : array { |
|
63 | + 'com.google.GoogleMobile/' => new props('start', function(string $value, int $i, array $tokens, string $match) use ($fn) : array { |
|
64 | 64 | return \array_merge($fn['appslash']($value, $i, $tokens, $match), [ |
65 | 65 | 'category' => 'mobile' |
66 | 66 | ]); |
67 | 67 | }), |
68 | 68 | 'com.google.' => new props('start', $fn['appslash']), |
69 | - 'Instagram' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
69 | + 'Instagram' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
70 | 70 | $parts = \explode(' ', $value, 4); |
71 | 71 | $data = [ |
72 | 72 | 'type' => 'human', |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'Viber/' => new props('start', $fn['appslash']), |
154 | 154 | |
155 | 155 | // special parser for Facebook app because it is completely different to any other |
156 | - 'FBAN/' => new props('any', function (string $value) : array { |
|
156 | + 'FBAN/' => new props('any', function(string $value) : array { |
|
157 | 157 | $map = [ |
158 | 158 | 'FBAN/MessengerLiteForiOS' => [ |
159 | 159 | 'type' => 'human', |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | 'model' => \mb_substr($value, 5) |
208 | 208 | ]), |
209 | 209 | 'FBLC/' => new props('start', $fn['langslash']), |
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 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $map = [ |
22 | 22 | 'YaApp_iOS' => 'Yandex', |
23 | 23 | 'YaApp_Android' => 'Yandex Start', |
24 | - 'YaSearchBrowser' => 'Yandex Alice', |
|
24 | + 'YaSearchBrowser' => 'Yandex Alice', |
|
25 | 25 | 'YaSearchApp' => 'Yandex', |
26 | 26 | 'YaBrowser' => 'Yandex', |
27 | 27 | 'LinkedInApp' => 'LinkedIn', |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | ]), |
144 | 144 | 'OculusBrowser/' => new props('start', $fn['appslash']), |
145 | 145 | 'YaApp_Android/' => new props('start', $fn['appslash']), |
146 | - 'YaSearchBrowser/' => new props('start', $fn['appslash']), |
|
146 | + 'YaSearchBrowser/' => new props('start', $fn['appslash']), |
|
147 | 147 | 'YaBrowser/' => new props('start', $fn['appslash']), |
148 | 148 | 'choqok/' => new props('start', $fn['appslash']), |
149 | 149 | 'PowerShell/' => new props('start', $fn['appslash']), |
@@ -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 | /** |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public static function get() : array { |
16 | 16 | $fn = [ |
17 | - 'platformlinux' => function (string $value) : array { |
|
17 | + 'platformlinux' => function(string $value) : array { |
|
18 | 18 | if (!\str_starts_with($value, 'Red Hat/') && ($platform = \mb_strstr($value, ' ', true)) !== false) { |
19 | 19 | $value = $platform; |
20 | 20 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | 'platformversion' => $parts[1] ?? null |
34 | 34 | ]; |
35 | 35 | }, |
36 | - 'platformwindows' => function (string $value) : array { |
|
36 | + 'platformwindows' => function(string $value) : array { |
|
37 | 37 | $mapping = [ |
38 | 38 | '5.0' => '2000', |
39 | 39 | '5.1' => 'XP', |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | 'platformversion' => $mapping[$version] ?? $version |
60 | 60 | ]; |
61 | 61 | }, |
62 | - 'android' => function (string $value, int $i, array $tokens) : array { |
|
62 | + 'android' => function(string $value, int $i, array $tokens) : array { |
|
63 | 63 | $os = \explode(' ', $value, 3); |
64 | 64 | |
65 | 65 | // skip language |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | // platforms |
83 | 83 | 'Windows NT ' => new props('any', $fn['platformwindows']), |
84 | - 'Windows Phone' => new props('start', function (string $value) : array { |
|
84 | + 'Windows Phone' => new props('start', function(string $value) : array { |
|
85 | 85 | $version = \mb_substr($value, 14); |
86 | 86 | return [ |
87 | 87 | 'type' => 'human', |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | 'platformversion' => \mb_substr($value, 5) |
124 | 124 | ]), |
125 | 125 | 'Windows' => new props('any', $fn['platformwindows']), |
126 | - 'Mac OS X' => new props('any', function (string $value) : array { |
|
126 | + 'Mac OS X' => new props('any', function(string $value) : array { |
|
127 | 127 | $version = \str_replace('_', '.', \mb_substr($value, \mb_stripos($value, 'Mac OS X') + 9)); |
128 | 128 | $register = $version && \intval(\explode('.', $version)[1] ?? 0) >= 6 ? 64 : null; |
129 | 129 | return [ |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | 'platform' => 'iOS', |
149 | 149 | 'platformversion' => \mb_substr($value, 4) |
150 | 150 | ]), |
151 | - 'CrOS' => new props('start', function (string $value) : array { |
|
151 | + 'CrOS' => new props('start', function(string $value) : array { |
|
152 | 152 | $parts = \explode(' ', $value); |
153 | 153 | return [ |
154 | 154 | 'type' => 'human', |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | 'platform' => 'Kindle', |
164 | 164 | 'platformversion' => \mb_substr($value, 7) |
165 | 165 | ]), |
166 | - 'Tizen' => new props('start', function (string $value) : array { |
|
166 | + 'Tizen' => new props('start', function(string $value) : array { |
|
167 | 167 | $parts = \explode(' ', $value, 2); |
168 | 168 | return [ |
169 | 169 | 'type' => 'human', |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | 'kernel' => 'unix', |
219 | 219 | 'platform' => 'Solaris', |
220 | 220 | ]), |
221 | - 'AmigaOS' => new props('any', function (string $value) : array { |
|
221 | + 'AmigaOS' => new props('any', function(string $value) : array { |
|
222 | 222 | if (($pos = \mb_stripos($value, 'AmigaOS')) !== false) { |
223 | 223 | $value = \mb_substr($value, $pos); |
224 | 224 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | 'platformversion' => isset($parts[1]) && \strspn($parts[1], '0123456789.-_') === \strlen($parts[1]) ? $parts[1] : null |
232 | 232 | ]; |
233 | 233 | }), |
234 | - 'Fuchsia' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
234 | + 'Fuchsia' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
235 | 235 | $os = \explode(' ', $tokens[++$i], 2); |
236 | 236 | return [ |
237 | 237 | 'type' => 'human', |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | 'platformversion' => isset($os[1]) && \strspn($os[1], '0123456789.-_', \strlen($os[0])) === \strlen($os[1]) ? $os[1] : null |
242 | 242 | ]; |
243 | 243 | }), |
244 | - 'Maemo' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
244 | + 'Maemo' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
245 | 245 | $os = \explode(' ', $tokens[++$i], 2); |
246 | 246 | return [ |
247 | 247 | 'type' => 'human', |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | 'kernel' => 'Java VM', |
258 | 258 | 'platform' => $value |
259 | 259 | ]), |
260 | - 'Haiku' => new props('any', function (string $value) : array { |
|
260 | + 'Haiku' => new props('any', function(string $value) : array { |
|
261 | 261 | $parts = \explode('/', $value, 2); |
262 | 262 | return [ |
263 | 263 | 'type' => 'human', |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | 'platformversion' => $parts[1] ?? null |
268 | 268 | ]; |
269 | 269 | }), |
270 | - 'BeOS' => new props('start', function (string $value) : array { |
|
270 | + 'BeOS' => new props('start', function(string $value) : array { |
|
271 | 271 | $parts = \explode('/', $value, 2); |
272 | 272 | return [ |
273 | 273 | 'type' => 'human', |
@@ -279,14 +279,14 @@ discard block |
||
279 | 279 | }), |
280 | 280 | 'Android' => new props('exact', $fn['android']), |
281 | 281 | 'Android ' => new props('start', $fn['android']), |
282 | - 'Linux' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
282 | + 'Linux' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
283 | 283 | return [ |
284 | 284 | 'kernel' => 'Linux', |
285 | 285 | 'platform' => 'Linux', |
286 | 286 | 'platformversion' => \str_contains($tokens[$i + 1] ?? '', '.') && \strspn($tokens[$i + 1], '0123456789.') >= 3 ? \explode(' ', $tokens[$i + 1])[0] : null |
287 | 287 | ]; |
288 | 288 | }), |
289 | - 'X11' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
289 | + 'X11' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
290 | 290 | $os = \explode(' ', $tokens[++$i] ?? '', 2); |
291 | 291 | return [ |
292 | 292 | '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 | /** |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public static function get() : array { |
16 | 16 | return [ |
17 | - '{' => new props('any', function (string $value) : ?array { |
|
17 | + '{' => new props('any', function(string $value) : ?array { |
|
18 | 18 | if (($start = \mb_strpos($value, '{')) === false) { |
19 | 19 | |
20 | 20 | } elseif (($end = \mb_strpos($value, '}', $start)) !== false) { |