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
Push — master ( 778995...e0837d )
by Baptiste
03:36
created

UnsignedOctet::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
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
17
/**
18
 * Same as unsigned shortshort
19
 */
20
final class UnsignedOctet implements Value
21
{
22
    private static $definitionSet;
23
24
    private $value;
25
    private $original;
26
27 272
    public function __construct(Integer $octet)
28
    {
29 272
        $this->original = $octet;
30 272
    }
31
32 144
    public static function of(Integer $octet): self
33
    {
34 144
        if (!self::definitionSet()->contains($octet)) {
35 10
            throw new OutOfRangeValue($octet, self::definitionSet());
36
        }
37
38 134
        return new self($octet);
39
    }
40
41 164
    public static function fromStream(Readable $stream): Value
42
    {
43 164
        [, $octet] = \unpack('C', (string) $stream->read(1));
44
45 164
        return new self(new Integer($octet));
46
    }
47
48 168
    public function original(): Integer
49
    {
50 168
        return $this->original;
51
    }
52
53 270
    public function __toString(): string
54
    {
55 270
        return $this->value ?? $this->value = \chr($this->original->value());
56
    }
57
58 144
    public static function definitionSet(): Set
59
    {
60 144
        return self::$definitionSet ?? self::$definitionSet = Range::inclusive(
61 2
            new Integer(0),
62 144
            new Integer(255)
63
        );
64
    }
65
}
66