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 ( 081f57...404db9 )
by Baptiste
12s queued 11s
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\Transport\Frame\Value;
7
use Innmind\Math\{
8
    Algebra\Integer,
9
    DefinitionSet\Set,
10
    DefinitionSet\Range
11
};
12
use Innmind\Stream\Readable;
13
use Innmind\Immutable\Str;
14
15
final class SignedShortInteger implements Value
16
{
17
    private static $definitionSet;
18
19
    private $value;
20
    private $original;
21
22 9
    public function __construct(Integer $value)
23
    {
24 9
        $this->original = $value;
25 9
    }
26
27 4
    public static function fromStream(Readable $stream): Value
28
    {
29 4
        [, $value] = unpack('s', (string) $stream->read(2));
30
31 4
        return new self(new Integer($value));
32
    }
33
34 8
    public function original(): Integer
35
    {
36 8
        return $this->original;
37
    }
38
39 8
    public function __toString(): string
40
    {
41 8
        return $this->value ?? $this->value = pack('s', $this->original->value());
42
    }
43
44 1
    public static function definitionSet(): Set
45
    {
46 1
        return self::$definitionSet ?? self::$definitionSet = Range::inclusive(
47 1
            new Integer(-32768),
48 1
            new Integer(32767)
49
        );
50
    }
51
}
52