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

ShortString::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
ccs 6
cts 6
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\Transport\Frame\Value;
7
use Innmind\Math\Algebra\Integer;
8
use Innmind\Stream\Readable;
9
use Innmind\Immutable\Str;
10
11
final class ShortString implements Value
12
{
13
    private $value;
14
    private $original;
15
16 98
    public function __construct(Str $string)
17
    {
18 98
        $this->original = $string;
19 98
        $string = $string->toEncoding('ASCII');
20 98
        $this->value = (string) new UnsignedOctet(
21 98
            new Integer($string->length())
22
        );
23 97
        $this->value .= $string;
24 97
    }
25
26 69
    public static function fromStream(Readable $stream): Value
27
    {
28 69
        $length = UnsignedOctet::fromStream($stream)->original();
29
30 69
        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 72
    public function original(): Str
34
    {
35 72
        return $this->original;
36
    }
37
38 96
    public function __toString(): string
39
    {
40 96
        return $this->value;
41
    }
42
}
43