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 ( 081f57...404db9 )
by Baptiste
12s queued 11s
created

LongString   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __toString() 0 5 1
A fromStream() 0 5 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 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
    }
20
21 56
    public static function fromStream(Readable $stream): Value
22
    {
23 56
        $length = UnsignedLongInteger::fromStream($stream)->original();
24
25 56
        return new self($stream->read($length->value()));
26
    }
27
28 8
    public function original(): Str
29
    {
30 8
        return $this->original;
31
    }
32
33 64
    public function __toString(): string
34
    {
35 64
        return $this->value ?? $this->value = new UnsignedLongInteger(
36 64
            new Integer($this->original->toEncoding('ASCII')->length())
37 64
        ).$this->original;
38
    }
39
}
40