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

UnsignedShortInteger::definitionSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1.0156
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
};
16
use Innmind\Immutable\Str;
17
18
final class UnsignedShortInteger implements Value
19
{
20
    private static $definitionSet;
21
22
    private $value;
23
    private $original;
24
25 224
    public function __construct(Integer $value)
26
    {
27 224
        if (!self::definitionSet()->contains($value)) {
28 4
            throw new OutOfRangeValue($value, self::definitionSet());
29
        }
30
31 220
        $this->original = $value;
32 220
    }
33
34 130
    public static function fromString(Str $string): Value
35
    {
36 130
        $string = $string->toEncoding('ASCII');
37
38 130
        if ($string->length() !== 2) {
39 2
            throw new StringNotOfExpectedLength($string, 2);
40
        }
41
42 128
        [, $value] = unpack('n', (string) $string);
43
44 128
        return new self(new Integer($value));
45
    }
46
47 116
    public static function cut(Str $string): Str
48
    {
49 116
        return $string->toEncoding('ASCII')->substring(0, 2);
50
    }
51
52 150
    public function original(): Integer
53
    {
54 150
        return $this->original;
55
    }
56
57 218
    public function __toString(): string
58
    {
59 218
        return $this->value ?? $this->value = pack('n', $this->original->value());
60
    }
61
62 224
    public static function definitionSet(): Set
63
    {
64 224
        return self::$definitionSet ?? self::$definitionSet = Range::inclusive(
65
            new Integer(0),
66 224
            new Integer(65535)
67
        );
68
    }
69
}
70