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 ( 4cbc06...07baac )
by Baptiste
02:19
created

UnsignedLongLongInteger::definitionSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1.0156
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Frame\Value;
5
6
use Innmind\AMQP\{
7
    Transport\Frame\Value,
8
    Exception\OutOfRangeValue,
9
    Exception\StringNotOfExpectedLength
10
};
11
use Innmind\Math\{
12
    Algebra\Integer,
13
    Algebra\Number\Infinite,
14
    DefinitionSet\Set,
15
    DefinitionSet\Range
16
};
17
use Innmind\Immutable\Str;
18
19
final class UnsignedLongLongInteger implements Value
20
{
21
    private static $definitionSet;
22
23
    private $value;
24
    private $original;
25
26 94
    public function __construct(Integer $value)
27
    {
28 94
        if (!self::definitionSet()->contains($value)) {
29 2
            throw new OutOfRangeValue($value, self::definitionSet());
30
        }
31
32 92
        $this->original = $value;
33 92
    }
34
35 58
    public static function fromString(Str $string): Value
36
    {
37 58
        $string = $string->toEncoding('ASCII');
38
39 58
        if ($string->length() !== 8) {
40 2
            throw new StringNotOfExpectedLength($string, 8);
41
        }
42
43 56
        [, $value] = unpack('J', (string) $string);
44
45 56
        return new self(new Integer($value));
46
    }
47
48 56
    public static function cut(Str $string): Str
49
    {
50 56
        return $string->toEncoding('ASCII')->substring(0, 8);
51
    }
52
53 68
    public function original(): Integer
54
    {
55 68
        return $this->original;
56
    }
57
58 90
    public function __toString(): string
59
    {
60 90
        return $this->value ?? $this->value = pack('J', $this->original->value());
61
    }
62
63 94
    public static function definitionSet(): Set
64
    {
65 94
        return self::$definitionSet ?? self::$definitionSet = Range::inclusive(
66
            new Integer(0),
67 94
            Infinite::positive()
68
        );
69
    }
70
}
71