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 ( faae32...638f88 )
by Baptiste
03:29
created

SignedLongLongInteger   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 39
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fromString() 0 12 2
A cut() 0 4 1
A original() 0 4 1
A __toString() 0 4 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\StringNotOfExpectedLength
9
};
10
use Innmind\Math\Algebra\Integer;
11
use Innmind\Immutable\Str;
12
13
final class SignedLongLongInteger implements Value
14
{
15
    private $value;
16
    private $original;
17
18 13
    public function __construct(Integer $value)
19
    {
20 13
        $this->value = pack('q', $value->value());
21 13
        $this->original = $value;
22 13
    }
23
24 7
    public static function fromString(Str $string): Value
25
    {
26 7
        $string = $string->toEncoding('ASCII');
27
28 7
        if ($string->length() !== 8) {
29 1
            throw new StringNotOfExpectedLength($string, 8);
30
        }
31
32 6
        [, $value] = unpack('q', (string) $string);
1 ignored issue
show
Bug introduced by
The variable $value does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
33
34 6
        return new self(new Integer($value));
35
    }
36
37 6
    public static function cut(Str $string): Str
38
    {
39 6
        return $string->toEncoding('ASCII')->substring(0, 8);
40
    }
41
42 12
    public function original(): Integer
43
    {
44 12
        return $this->original;
45
    }
46
47 12
    public function __toString(): string
48
    {
49 12
        return $this->value;
50
    }
51
}
52