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.
Passed
Pull Request — develop (#1)
by Baptiste
01:41
created

UnsignedLongLongInteger   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 38
ccs 15
cts 16
cp 0.9375
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A fromStream() 0 5 1
A original() 0 3 1
A __construct() 0 7 2
A definitionSet() 0 5 1
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
};
10
use Innmind\Math\{
11
    Algebra\Integer,
12
    Algebra\Number\Infinite,
13
    DefinitionSet\Set,
14
    DefinitionSet\Range,
15
};
16
use Innmind\Stream\Readable;
17
18
final class UnsignedLongLongInteger implements Value
19
{
20
    private static $definitionSet;
21
22
    private $value;
23
    private $original;
24
25 47
    public function __construct(Integer $value)
26
    {
27 47
        if (!self::definitionSet()->contains($value)) {
28 1
            throw new OutOfRangeValue($value, self::definitionSet());
29
        }
30
31 46
        $this->original = $value;
32 46
    }
33
34 28
    public static function fromStream(Readable $stream): Value
35
    {
36 28
        [, $value] = unpack('J', (string) $stream->read(8));
37
38 28
        return new self(new Integer($value));
39
    }
40
41 34
    public function original(): Integer
42
    {
43 34
        return $this->original;
44
    }
45
46 45
    public function __toString(): string
47
    {
48 45
        return $this->value ?? $this->value = pack('J', $this->original->value());
49
    }
50
51 47
    public static function definitionSet(): Set
52
    {
53 47
        return self::$definitionSet ?? self::$definitionSet = Range::inclusive(
54
            new Integer(0),
55 47
            Infinite::positive()
56
        );
57
    }
58
}
59