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 ( 8cc0dc...800d8a )
by Baptiste
03:38
created

UnsignedLongInteger   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 43
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A original() 0 3 1
A definitionSet() 0 5 1
A __construct() 0 3 1
A fromStream() 0 5 1
A of() 0 7 2
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 130
    public function __construct(Integer $value)
25
    {
26 130
        $this->original = $value;
27 130
    }
28
29 67
    public static function of(Integer $value): self
30
    {
31 67
        if (!self::definitionSet()->contains($value)) {
32 2
            throw new OutOfRangeValue($value, self::definitionSet());
33
        }
34
35 65
        return new self($value);
36
    }
37
38 76
    public static function fromStream(Readable $stream): Value
39
    {
40 76
        [, $value] = \unpack('N', (string) $stream->read(4));
41
42 76
        return new self(new Integer($value));
43
    }
44
45 68
    public function original(): Integer
46
    {
47 68
        return $this->original;
48
    }
49
50 129
    public function __toString(): string
51
    {
52 129
        return $this->value ?? $this->value = \pack('N', $this->original->value());
53
    }
54
55 67
    public static function definitionSet(): Set
56
    {
57 67
        return self::$definitionSet ?? self::$definitionSet = Range::inclusive(
58 1
            new Integer(0),
59 67
            new Integer(4294967295)
60
        );
61
    }
62
}
63