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 ( 4cbc06...07baac )
by Baptiste
02:19
created

SignedOctet::definitionSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1.0156
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
    Exception\StringNotOfExpectedLength
10
};
11
use Innmind\Math\{
12
    Algebra\Integer,
13
    DefinitionSet\Set,
14
    DefinitionSet\Range
15
};
16
use Innmind\Immutable\Str;
17
18
/**
19
 * Same as shortshort
20
 */
21
final class SignedOctet implements Value
22
{
23
    private static $definitionSet;
24
25
    private $value;
26
    private $original;
27
28 24
    public function __construct(Integer $octet)
29
    {
30 24
        if (!self::definitionSet()->contains($octet)) {
31 4
            throw new OutOfRangeValue($octet, self::definitionSet());
32
        }
33
34 20
        $this->original = $octet;
35 20
    }
36
37 14
    public static function fromString(Str $string): Value
38
    {
39 14
        $string = $string->toEncoding('ASCII');
40
41 14
        if ($string->length() !== 1) {
42 2
            throw new StringNotOfExpectedLength($string, 1);
43
        }
44
45 12
        [, $value] = unpack('c', (string) $string);
46
47 12
        return new self(new Integer($value));
48
    }
49
50 12
    public static function cut(Str $string): Str
51
    {
52 12
        return $string->toEncoding('ASCII')->substring(0, 1);
53
    }
54
55 14
    public function original(): Integer
56
    {
57 14
        return $this->original;
58
    }
59
60 22
    public function __toString(): string
61
    {
62 22
        return $this->value ?? $this->value = pack('c', $this->original->value());
63
    }
64
65 24
    public static function definitionSet(): Set
66
    {
67 24
        return self::$definitionSet ?? self::$definitionSet = Range::inclusive(
68
            new Integer(-128),
69 24
            new Integer(127)
70
        );
71
    }
72
}
73