@@ -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 categories { |
@@ -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 crawlers { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | 'category' => 'feed' |
142 | 142 | ] |
143 | 143 | )), |
144 | - 'crawler' => function (string $value) : array { |
|
144 | + 'crawler' => function(string $value) : array { |
|
145 | 145 | $parts = \explode('/', $value, 2); |
146 | 146 | $map = [ |
147 | 147 | 'baiduspider' => 'search', |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | 'type' => 'robot', |
165 | 165 | 'categpry' => 'scraper' |
166 | 166 | ]), |
167 | - 'Moblie' => new props('exact', [ // some samsung devices mispelt it |
|
167 | + 'Moblie' => new props('exact', [// some samsung devices mispelt it |
|
168 | 168 | 'type' => 'robot', |
169 | 169 | 'category' => 'scraper' |
170 | 170 | ]), |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'Siteimprove.com' => new props('any', $fn['crawler']), |
183 | 183 | 'CyotekWebCopy' => new props('start', $fn['scraper']), |
184 | 184 | 'Google Page Speed Insights' => new props('exact', $fn['validator']), |
185 | - 'Qwantify' => new props('start', function (string $value) : array { |
|
185 | + 'Qwantify' => new props('start', function(string $value) : array { |
|
186 | 186 | $parts = \explode('/', $value, 3); |
187 | 187 | return [ |
188 | 188 | 'type' => 'robot', |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | 'Uptime/' => new props('start', $fn['monitor']), |
226 | 226 | 'HostTracker/' => new props('start', $fn['monitor']), |
227 | 227 | 'NCSC Web Check [email protected]' => new props('exact', $fn['monitor']), |
228 | - 'Pingdom.com' => new props('start', function (string $value) : array { |
|
228 | + 'Pingdom.com' => new props('start', function(string $value) : array { |
|
229 | 229 | $version = \explode('_', \trim($value, '_')); |
230 | 230 | return [ |
231 | 231 | 'type' => 'robot', |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | 'MicrosoftPreview/' => new props('start', $fn['feed']), |
253 | 253 | 'YahooMailProxy' => new props('exact', $fn['feed']), |
254 | 254 | 'PhxBot/' => new props('start', $fn['feed']), // proton mail |
255 | - 'Pleroma' => new props('start', fn (string $value) : array => [ // mastodon |
|
255 | + 'Pleroma' => new props('start', fn (string $value) : array => [// mastodon |
|
256 | 256 | 'type' => 'robot', |
257 | 257 | 'category' => 'feed', |
258 | 258 | 'app' => 'Mastodon', |
259 | 259 | 'appname' => 'Pleroma', |
260 | 260 | 'appversion' => \mb_substr($value, 8) |
261 | 261 | ]), |
262 | - 'Outlook-Android/' => new props('start', fn (string $value) : array => [ // mastodon |
|
262 | + 'Outlook-Android/' => new props('start', fn (string $value) : array => [// mastodon |
|
263 | 263 | 'type' => 'robot', |
264 | 264 | 'category' => 'feed', |
265 | 265 | 'app' => 'Outlook', |
@@ -267,15 +267,15 @@ discard block |
||
267 | 267 | 'platform' => 'Android', |
268 | 268 | 'appversion' => \mb_substr($value, 16) |
269 | 269 | ]), |
270 | - 'Outlook-iOS/' => new props('start', fn (string $value, int $i, array $tokens) : array => [ // mastodon |
|
270 | + 'Outlook-iOS/' => new props('start', fn (string $value, int $i, array $tokens) : array => [// mastodon |
|
271 | 271 | 'type' => 'robot', |
272 | 272 | 'category' => 'feed', |
273 | 273 | 'app' => 'Outlook', |
274 | 274 | 'appname' => 'Outlook-iOS', |
275 | 275 | 'platform' => 'iOS', |
276 | - 'appversion' => $tokens[$i+1] ?? \mb_substr($value, 12) |
|
276 | + 'appversion' => $tokens[$i + 1] ?? \mb_substr($value, 12) |
|
277 | 277 | ]), |
278 | - 'OutlookMobileCloudService-Autodetect/' => new props('start', fn (string $value) : array => [ // mastodon |
|
278 | + 'OutlookMobileCloudService-Autodetect/' => new props('start', fn (string $value) : array => [// mastodon |
|
279 | 279 | 'type' => 'robot', |
280 | 280 | 'category' => 'feed', |
281 | 281 | 'app' => 'Outlook', |
@@ -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 []; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } |
153 | 153 | return $fn['platformwindows']($value, $i, $tokens); |
154 | 154 | }), |
155 | - 'Mac OS X' => new props('any', function (string $value) : array { |
|
155 | + 'Mac OS X' => new props('any', function(string $value) : array { |
|
156 | 156 | $version = \str_replace('_', '.', \mb_substr($value, \mb_stripos($value, 'Mac OS X') + 9)); |
157 | 157 | $register = $version && \intval(\explode('.', $version)[1] ?? 0) >= 6 ? 64 : null; |
158 | 158 | return [ |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | 'platform' => 'iOS', |
184 | 184 | 'platformversion' => \str_replace('_', '.', \mb_substr($value, 4)) |
185 | 185 | ]), |
186 | - 'CrOS' => new props('start', function (string $value) : array { |
|
186 | + 'CrOS' => new props('start', function(string $value) : array { |
|
187 | 187 | $parts = \explode(' ', $value); |
188 | 188 | return [ |
189 | 189 | 'type' => 'human', |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | 'platform' => 'Kindle', |
199 | 199 | 'platformversion' => \mb_substr($value, 7) |
200 | 200 | ]), |
201 | - 'Tizen' => new props('start', function (string $value) : array { |
|
201 | + 'Tizen' => new props('start', function(string $value) : array { |
|
202 | 202 | $parts = \explode(' ', $value, 2); |
203 | 203 | return [ |
204 | 204 | 'type' => 'human', |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | 'platformversion' => $parts[1] ?? null |
209 | 209 | ]; |
210 | 210 | }), |
211 | - 'KAIOS/' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
211 | + 'KAIOS/' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
212 | 212 | |
213 | 213 | // find device |
214 | 214 | foreach ($tokens AS $i => $item) { |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | 'kernel' => 'unix', |
282 | 282 | 'platform' => 'Solaris', |
283 | 283 | ]), |
284 | - 'AmigaOS' => new props('any', function (string $value) : array { |
|
284 | + 'AmigaOS' => new props('any', function(string $value) : array { |
|
285 | 285 | if (($pos = \mb_stripos($value, 'AmigaOS')) !== false) { |
286 | 286 | $value = \mb_substr($value, $pos); |
287 | 287 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | 'platformversion' => isset($parts[1]) && \strspn($parts[1], '0123456789.-_') === \strlen($parts[1]) ? $parts[1] : null |
295 | 295 | ]; |
296 | 296 | }), |
297 | - 'Fuchsia' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
297 | + 'Fuchsia' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
298 | 298 | $os = \explode(' ', $tokens[++$i], 2); |
299 | 299 | return [ |
300 | 300 | 'type' => 'human', |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | 'platformversion' => isset($os[1]) && \strspn($os[1], '0123456789.-_', \strlen($os[0])) === \strlen($os[1]) ? $os[1] : null |
305 | 305 | ]; |
306 | 306 | }), |
307 | - 'Maemo' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
307 | + 'Maemo' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
308 | 308 | $os = \explode(' ', $tokens[++$i], 2); |
309 | 309 | return [ |
310 | 310 | 'type' => 'human', |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'kernel' => 'Java VM', |
321 | 321 | 'platform' => $value |
322 | 322 | ]), |
323 | - 'Haiku' => new props('any', function (string $value) : array { |
|
323 | + 'Haiku' => new props('any', function(string $value) : array { |
|
324 | 324 | $parts = \explode('/', $value, 2); |
325 | 325 | return [ |
326 | 326 | 'type' => 'human', |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | 'platformversion' => $parts[1] ?? null |
331 | 331 | ]; |
332 | 332 | }), |
333 | - 'BeOS' => new props('start', function (string $value) : array { |
|
333 | + 'BeOS' => new props('start', function(string $value) : array { |
|
334 | 334 | $parts = \explode('/', $value, 2); |
335 | 335 | return [ |
336 | 336 | 'type' => 'human', |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | }), |
343 | 343 | 'Android' => new props('exact', $fn['android']), |
344 | 344 | 'Android ' => new props('start', $fn['android']), |
345 | - 'Linux' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
345 | + 'Linux' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
346 | 346 | return [ |
347 | 347 | 'kernel' => 'Linux', |
348 | 348 | 'platform' => 'Linux', |
349 | 349 | 'platformversion' => \str_contains($tokens[$i + 1] ?? '', '.') && \strspn($tokens[$i + 1], '0123456789.') >= 3 ? \explode(' ', $tokens[$i + 1])[0] : null |
350 | 350 | ]; |
351 | 351 | }), |
352 | - 'X11' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
352 | + 'X11' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
353 | 353 | $os = \explode(' ', $tokens[++$i] ?? '', 2); |
354 | 354 | return [ |
355 | 355 | 'category' => 'desktop', |