• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mimmi20 / browser-detector / 18531733666

15 Oct 2025 02:08PM UTC coverage: 95.76% (-0.5%) from 96.217%
18531733666

push

github

web-flow
Merge pull request #1004 from mimmi20/updates

add new devices

193 of 233 new or added lines in 23 files covered. (82.83%)

3 existing lines in 1 file now uncovered.

7996 of 8350 relevant lines covered (95.76%)

13.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/Parser/Header/SecChUaPlatformVersion.php
1
<?php
2

3
/**
4
 * This file is part of the browser-detector package.
5
 *
6
 * Copyright (c) 2012-2025, Thomas Mueller <mimmi20@live.de>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types = 1);
13

14
namespace BrowserDetector\Parser\Header;
15

16
use BrowserDetector\Parser\Header\Exception\VersionContainsDerivateException;
17
use BrowserDetector\Version\ForcedNullVersion;
18
use BrowserDetector\Version\VersionInterface;
19
use Override;
20
use UaParser\PlatformVersionInterface;
21

22
use function assert;
23
use function is_int;
24
use function mb_strpos;
25
use function mb_strtolower;
26
use function mb_substr;
27
use function mb_trim;
28

29
final class SecChUaPlatformVersion implements PlatformVersionInterface
30
{
31
    use SetVersionTrait;
32

33
    /** @throws void */
34
    #[Override]
10✔
35
    public function hasPlatformVersion(string $value): bool
36
    {
37
        $value = mb_trim($value, '"\\\'');
10✔
38

39
        return $value !== '';
10✔
40
    }
41

42
    /** @throws VersionContainsDerivateException */
43
    #[Override]
10✔
44
    public function getPlatformVersion(string $value, string | null $code = null): VersionInterface
45
    {
46
        $value = mb_trim($value, '"\\\'');
10✔
47

48
        if ($value === '') {
10✔
49
            return new ForcedNullVersion();
1✔
50
        }
51

52
        if ($code === null || mb_strtolower($code) !== 'windows') {
9✔
53
            $derivatePosition = mb_strpos($value, ';');
2✔
54

55
            assert($derivatePosition === false || is_int($derivatePosition));
2✔
56

57
            if ($derivatePosition !== false) {
2✔
NEW
58
                $derivate = mb_trim(mb_substr($value, $derivatePosition + 1));
×
59

NEW
60
                $exception = new VersionContainsDerivateException();
×
NEW
61
                $exception->setDerivate($derivate);
×
62

NEW
63
                throw $exception;
×
64
            }
65

66
            return $this->setVersion($value);
2✔
67
        }
68

69
        $windowsVersion = (float) $value;
7✔
70

71
        if ($windowsVersion < 1) {
7✔
72
            $windowsVersion      = (int) ($windowsVersion * 10);
4✔
73
            $minorVersionMapping = [1 => '7', 2 => '8', 3 => '8.1'];
4✔
74

75
            return $this->setVersion($minorVersionMapping[$windowsVersion] ?? $value);
4✔
76
        }
77

78
        if ($windowsVersion < 11) {
3✔
79
            return $this->setVersion('10');
1✔
80
        }
81

82
        return $this->setVersion('11');
2✔
83
    }
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc