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   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 95.24%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 7
dl 0
loc 52
ccs 20
cts 21
cp 0.9524
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A fromString() 0 12 2
A cut() 0 4 1
A original() 0 4 1
A __toString() 0 4 1
A definitionSet() 0 7 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
    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