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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 34
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A original() 0 3 1
A __construct() 0 3 1
A definitionSet() 0 5 1
A fromStream() 0 5 1
A __toString() 0 3 1
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