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.

AbstractWebClient::getPatterns()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
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
namespace Fam\Util\UserAgentParser;
14
15
/**
16
 * Base class for web clients
17
 *
18
 * @package    Util
19
 * @subpackage UserAgentParser
20
 * @author     Dejan Spasic <[email protected]>
21
 * @version    @@PACKAGE_VERSION@@
22
 */
23
abstract class AbstractWebClient implements WebClient
24
{
25
    /**
26
     * @var string
27
     */
28
    private $version = "";
29
30 16
    public function match(string $userAgent): bool
31
    {
32 16
        foreach ($this->getPatterns() as $currentPattern) {
33 15
            $matches = array();
34 15
            if (preg_match($currentPattern, $userAgent, $matches)) {
35 10
                $this->version = $matches[1];
36
37 15
                return true;
38
            }
39
        }
40
41 6
        return false;
42
    }
43
44
    abstract protected function getPatterns(): array;
45
46
    /**
47
     * @param string|WebClient $webClient
48
     *
49
     * @return boolean
50
     *
51
     * @throws \InvalidArgumentException
52
     */
53 3
    public function isNameEquals($webClient): bool
54
    {
55 3
        if ($webClient instanceof WebClient) {
56 1
            $name = $webClient->getName();
57 2
        } elseif (is_string($webClient)) {
58 1
            $name = $webClient;
59
        } else {
60 1
            throw new \InvalidArgumentException(
61 1
                'Invalid argument given. Excpected argument are string or ' . WebClient::class
62
            );
63
        }
64
65 2
        return strtoupper($this->getName()) === strtoupper($name);
66
    }
67
68 5
    public function getVersion(): string
69
    {
70 5
        return $this->version;
71
    }
72
73 2
    public function isVersionEquals(string $version): bool
74
    {
75 2
        return $this->getVersion() === $version;
76
    }
77
78
    /**
79
     * @param string $lowerVersion
80
     * @param string $greaterVersion
81
     *
82
     * @return boolean
83
     */
84 2
    public function isVersionBetween(string $lowerVersion, string $greaterVersion): bool
85
    {
86 2
        return version_compare($lowerVersion, $this->getVersion(), "<=")
87 2
            && version_compare($greaterVersion, $this->getVersion(), ">=");
88
    }
89
}
90