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 ( faae32...638f88 )
by Baptiste
03:29
created

UnsignedLongInteger::original()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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
    DefinitionSet\Set,
14
    DefinitionSet\Range,
15
    DefinitionSet\Integers
16
};
17
use Innmind\Immutable\Str;
18
19
final class UnsignedLongInteger implements Value
20
{
21
    private static $definitionSet;
22
23
    private $value;
24
    private $original;
25
26 32
    public function __construct(Integer $value)
27
    {
28 32
        if (!self::definitionSet()->contains($value)) {
29 2
            throw new OutOfRangeValue($value, self::definitionSet());
30
        }
31
32 30
        $this->value = pack('N', $value->value());
33 30
        $this->original = $value;
34 30
    }
35
36 18
    public static function fromString(Str $string): Value
37
    {
38 18
        $string = $string->toEncoding('ASCII');
39
40 18
        if ($string->length() !== 4) {
41 1
            throw new StringNotOfExpectedLength($string, 4);
42
        }
43
44 17
        [, $value] = unpack('N', (string) $string);
1 ignored issue
show
Bug introduced by
The variable $value does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
45
46 17
        return new self(new Integer($value));
47
    }
48
49 7
    public static function cut(Str $string): Str
50
    {
51 7
        return $string->toEncoding('ASCII')->substring(0, 4);
52
    }
53
54 17
    public function original(): Integer
55
    {
56 17
        return $this->original;
57
    }
58
59 22
    public function __toString(): string
60
    {
61 22
        return $this->value;
62
    }
63
64 32
    public static function definitionSet(): Set
65
    {
66 32
        return self::$definitionSet ?? self::$definitionSet = Range::inclusive(
67
            new Integer(0),
68
            new Integer(4294967295)
69 32
        )->intersect(new Integers);
70
    }
71
}
72