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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 30
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A fromStream() 0 5 1
A __toString() 0 3 1
A 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 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