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.
Test Failed
Push — 3.0.x ( bfaf99...4185ba )
by Nicolas
05:44
created

VersionComparator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
3
/**
4
 * @package core
5
 */
6
7
use \Composer\Semver\Comparator;
8
9
/**
10
 * The VersionComparator provides functions to compare semver compatible versions.
11
 * It uses \Composer\Semver\Comparator under the hood but translate the `.x`
12
 * notation used in Symphony in `.*` for semver.
13
 * @since Symphony 3.0.0
14
 */
15
class VersionComparator
16
{
17
    /**
18
     * The base version used to compare
19
     *
20
     * @var string
21
     */
22
    private $base;
23
24
    /**
25
     * Creates a new version comparator object, based on $version.
26
     *
27
     * @param string $version
28
     */
29
    public function __construct($version)
30
    {
31
        General::ensureType([
32
            'version' => ['var' => $version, 'type' => 'string'],
33
        ]);
34
        $this->base = $version;
35
    }
36
37
    public function fixVersion($version)
38
    {
39
        $version = str_replace('.x', '.*', $version);
40
        return $version;
41
    }
42
43
    public function lessThan($version)
44
    {
45
        return Comparator::lessThan($this->base, $this->fixVersion($version));
46
    }
47
48
    public function greaterThan($version)
49
    {
50
        return Comparator::greaterThan($this->base, $this->fixVersion($version));
51
    }
52
53
    public function compareTo($version)
54
    {
55
        $version = $this->fixVersion($version);
56
        if ($this->base === $version) {
57
            return 0;
58
        }
59
        return $this->lessThan($version) ? -1 : 1;
60
    }
61
62
    public static function compare($a, $b)
63
    {
64
        return (new VersionComparator($a))->compareTo($b);
65
    }
66
}
67