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

LongString::fromString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A LongString::original() 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\Algebra\Integer;
8
use Innmind\Stream\Readable;
9
use Innmind\Immutable\Str;
10
11
final class LongString implements Value
12
{
13
    private $value;
14
    private $original;
15
16 62
    public function __construct(Str $string)
17
    {
18 62
        $this->original = $string;
19 62
        $string = $string->toEncoding('ASCII');
20 62
        $this->value = (string) new UnsignedLongInteger(
21 62
            new Integer($string->length())
22
        );
23 62
        $this->value .= $string;
24 62
    }
25
26 56
    public static function fromStream(Readable $stream): Value
27
    {
28 56
        $length = UnsignedLongInteger::fromStream($stream)->original();
29
30 56
        return new self($stream->read($length->value()));
1 ignored issue
show
Bug introduced by
It seems like $length->value() can also be of type double; however, parameter $length of Innmind\Stream\Readable::read() does only seem to accept integer|null, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
        return new self($stream->read(/** @scrutinizer ignore-type */ $length->value()));
Loading history...
31
    }
32
33 8
    public function original(): Str
34
    {
35 8
        return $this->original;
36
    }
37
38 64
    public function __toString(): string
39
    {
40 64
        return $this->value;
41
    }
42
}
43