@@ -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,9 +195,9 @@ 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 | - 'CrOS' => new props('start', function (string $value) : array { |
|
200 | + 'CrOS' => new props('start', function(string $value) : array { |
|
201 | 201 | $parts = \explode(' ', $value); |
202 | 202 | return [ |
203 | 203 | 'type' => 'human', |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | 'platform' => 'Kindle', |
213 | 213 | 'platformversion' => \mb_substr($value, 7) |
214 | 214 | ]), |
215 | - 'Tizen' => new props('start', function (string $value) : array { |
|
215 | + 'Tizen' => new props('start', function(string $value) : array { |
|
216 | 216 | $parts = \explode(' ', $value, 2); |
217 | 217 | return [ |
218 | 218 | 'type' => 'human', |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | 'platformversion' => $parts[1] ?? null |
223 | 223 | ]; |
224 | 224 | }), |
225 | - 'KAIOS/' => new props('start', function (string $value, int $i, array $tokens) : array { |
|
225 | + 'KAIOS/' => new props('start', function(string $value, int $i, array $tokens) : array { |
|
226 | 226 | |
227 | 227 | // find device |
228 | 228 | foreach ($tokens AS $i => $item) { |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | 'kernel' => 'unix', |
296 | 296 | 'platform' => 'Solaris', |
297 | 297 | ]), |
298 | - 'AmigaOS' => new props('any', function (string $value) : array { |
|
298 | + 'AmigaOS' => new props('any', function(string $value) : array { |
|
299 | 299 | if (($pos = \mb_stripos($value, 'AmigaOS')) !== false) { |
300 | 300 | $value = \mb_substr($value, $pos); |
301 | 301 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | 'platformversion' => isset($parts[1]) && \strspn($parts[1], '0123456789.-_') === \strlen($parts[1]) ? $parts[1] : null |
309 | 309 | ]; |
310 | 310 | }), |
311 | - 'Fuchsia' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
311 | + 'Fuchsia' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
312 | 312 | $os = \explode(' ', $tokens[++$i], 2); |
313 | 313 | return [ |
314 | 314 | 'type' => 'human', |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | 'platformversion' => isset($os[1]) && \strspn($os[1], '0123456789.-_', \strlen($os[0])) === \strlen($os[1]) ? $os[1] : null |
319 | 319 | ]; |
320 | 320 | }), |
321 | - 'Maemo' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
321 | + 'Maemo' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
322 | 322 | $os = \explode(' ', $tokens[++$i], 2); |
323 | 323 | return [ |
324 | 324 | 'type' => 'human', |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | 'kernel' => 'Java VM', |
335 | 335 | 'platform' => $value |
336 | 336 | ]), |
337 | - 'Haiku' => new props('any', function (string $value) : array { |
|
337 | + 'Haiku' => new props('any', function(string $value) : array { |
|
338 | 338 | $parts = \explode('/', $value, 2); |
339 | 339 | return [ |
340 | 340 | 'type' => 'human', |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | 'platformversion' => $parts[1] ?? null |
345 | 345 | ]; |
346 | 346 | }), |
347 | - 'BeOS' => new props('start', function (string $value) : array { |
|
347 | + 'BeOS' => new props('start', function(string $value) : array { |
|
348 | 348 | $parts = \explode('/', $value, 2); |
349 | 349 | return [ |
350 | 350 | 'type' => 'human', |
@@ -361,14 +361,14 @@ discard block |
||
361 | 361 | 'platformversion' => \explode('/', $value, 3)[1] ?: null |
362 | 362 | ]), |
363 | 363 | 'Android ' => new props('start', $fn['android']), |
364 | - 'Linux' => new props('any', function (string $value, int $i, array $tokens) : array { |
|
364 | + 'Linux' => new props('any', function(string $value, int $i, array $tokens) : array { |
|
365 | 365 | return [ |
366 | 366 | 'kernel' => 'Linux', |
367 | 367 | 'platform' => 'Linux', |
368 | 368 | 'platformversion' => \str_contains($tokens[$i + 1] ?? '', '.') && \strspn($tokens[$i + 1], '0123456789.') >= 3 ? \explode(' ', $tokens[$i + 1])[0] : null |
369 | 369 | ]; |
370 | 370 | }), |
371 | - 'X11' => new props('exact', function (string $value, int $i, array $tokens) : array { |
|
371 | + 'X11' => new props('exact', function(string $value, int $i, array $tokens) : array { |
|
372 | 372 | $os = \explode(' ', $tokens[++$i] ?? '', 2); |
373 | 373 | return [ |
374 | 374 | 'category' => 'desktop', |