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

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