GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AbstractOperatingSystem::match()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
crap 3
1
<?php
2
/**
3
 * (c) 2008 Dejan Spasic <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @package    Util
9
 * @subpackage UserAgentParser
10
 * @author     Dejan Spasic <[email protected]>
11
 * @version    GIT: $Id:$
12
 */
13
14
namespace Fam\Util\UserAgentParser;
15
16
/**
17
 * Reproduce a windows
18
 *
19
 * @package    Util
20
 * @subpackage UserAgentParser
21
 * @author     Dejan Spasic <[email protected]>
22
 * @version    @@PACKAGE_VERSION@@
23
 */
24
abstract class AbstractOperatingSystem implements OperatingSystem
25
{
26
    /**
27
     * @param string $userAgent
28
     *
29
     * @return boolean
30
     */
31 19
    public function match(string $userAgent): bool
32
    {
33 19
        foreach ($this->getPatterns() as $currentPattern) {
34 18
            if (preg_match($currentPattern, $userAgent)) {
35 18
                return true;
36
            }
37
        }
38
39 5
        return false;
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    abstract protected function getPatterns(): array;
46
47
    /**
48
     * @param string|OperatingSystem $operatingSystem
49
     *
50
     * @return boolean
51
     *
52
     * @throws \InvalidArgumentException
53
     */
54 4
    public function equals($operatingSystem): bool
55
    {
56 4
        if ($operatingSystem instanceof OperatingSystem) {
57 1
            $name = $operatingSystem->getName();
58 3
        } elseif (is_string($operatingSystem)) {
59 2
            $name = $operatingSystem;
60
        } else {
61 1
            throw new \InvalidArgumentException(
62 1
                'Invalid argument given. Expected argument are string or ' . OperatingSystem::class
63
            );
64
        }
65
66 3
        return strtoupper($this->getName()) === strtoupper($name);
67
    }
68
}
69