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

SignedOctet::fromString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 2
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A SignedOctet::original() 0 3 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
};
10
use Innmind\Math\{
11
    Algebra\Integer,
12
    DefinitionSet\Set,
13
    DefinitionSet\Range
14
};
15
use Innmind\Stream\Readable;
16
17
/**
18
 * Same as shortshort
19
 */
20
final class SignedOctet implements Value
21
{
22
    private static $definitionSet;
23
24
    private $value;
25
    private $original;
26
27 12
    public function __construct(Integer $octet)
28
    {
29 12
        if (!self::definitionSet()->contains($octet)) {
30 2
            throw new OutOfRangeValue($octet, self::definitionSet());
31
        }
32
33 10
        $this->original = $octet;
34 10
    }
35
36 6
    public static function fromStream(Readable $stream): Value
37
    {
38 6
        [, $value] = unpack('c', (string) $stream->read(1));
39
40 6
        return new self(new Integer($value));
41
    }
42
43 7
    public function original(): Integer
44
    {
45 7
        return $this->original;
46
    }
47
48 11
    public function __toString(): string
49
    {
50 11
        return $this->value ?? $this->value = pack('c', $this->original->value());
51
    }
52
53 12
    public static function definitionSet(): Set
54
    {
55 12
        return self::$definitionSet ?? self::$definitionSet = Range::inclusive(
56
            new Integer(-128),
57 12
            new Integer(127)
58
        );
59
    }
60
}
61