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.
Completed
Push — develop ( 14a217...c3bf76 )
by Baptiste
03:06
created

Version::compatibleWith()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 3
nop 1
crap 4
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Protocol;
5
6
use Innmind\AMQP\Exception\DomainException;
7
8
final class Version
9
{
10
    private $major;
11
    private $minor;
12
    private $fix;
13
14 69
    public function __construct(int $major, int $minor, int $fix)
15
    {
16 69
        if (min($major, $minor, $fix) < 0) {
17 3
            throw new DomainException;
18
        }
19
20 66
        $this->major = $major;
21 66
        $this->minor = $minor;
22 66
        $this->fix = $fix;
23 66
    }
24
25 2
    public function major(): int
26
    {
27 2
        return $this->major;
28
    }
29
30 2
    public function minor(): int
31
    {
32 2
        return $this->minor;
33
    }
34
35 2
    public function fix(): int
36
    {
37 2
        return $this->fix;
38
    }
39
40 1
    public function higherThan(self $version): bool
41
    {
42 1
        if ($this->major !== $version->major) {
43 1
            return $this->major > $version->major;
44
        }
45
46 1
        if ($this->minor !== $version->minor) {
47 1
            return $this->minor > $version->minor;
48
        }
49
50 1
        return $this->fix > $version->fix;
51
    }
52
53 6
    public function compatibleWith(self $version): bool
54
    {
55 6
        if ($this->major === 0 && $version->major === 0) {
56 5
            return $this->minor === $version->minor;
57
        }
58
59 2
        if ($this->major !== $version->major) {
60 2
            return false;
61
        }
62
63 1
        return $this->minor >= $version->minor;
64
    }
65
66 4
    public function __toString(): string
67
    {
68 4
        return sprintf(
69 4
            "AMQP\x00%s%s%s",
70 4
            chr($this->major),
71 4
            chr($this->minor),
72 4
            chr($this->fix)
73
        );
74
    }
75
}
76