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

SignedShortInteger::fromStream()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
use Innmind\Immutable\Str;
17
18
final class SignedShortInteger implements Value
19
{
20
    private static $definitionSet;
21
22
    private $value;
23
    private $original;
24
25 11
    public function __construct(Integer $value)
26
    {
27 11
        if (!self::definitionSet()->contains($value)) {
28 2
            throw new OutOfRangeValue($value, self::definitionSet());
29
        }
30
31 9
        $this->original = $value;
32 9
    }
33
34 4
    public static function fromStream(Readable $stream): Value
35
    {
36 4
        [, $value] = unpack('s', (string) $stream->read(2));
37
38 4
        return new self(new Integer($value));
39
    }
40
41 8
    public function original(): Integer
42
    {
43 8
        return $this->original;
44
    }
45
46 8
    public function __toString(): string
47
    {
48 8
        return $this->value ?? $this->value = pack('s', $this->original->value());
49
    }
50
51 11
    public static function definitionSet(): Set
52
    {
53 11
        return self::$definitionSet ?? self::$definitionSet = Range::inclusive(
54 1
            new Integer(-32768),
55 11
            new Integer(32767)
56
        );
57
    }
58
}
59