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

Frame::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 0
cts 22
cp 0
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 24
nc 1
nop 4
crap 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport;
5
6
use Innmind\AMQP\Transport\Frame\{
7
    Type,
8
    Channel,
9
    Method,
10
    Value,
11
    Value\UnsignedOctet,
12
    Value\UnsignedShortInteger,
13
    Value\UnsignedLongInteger
14
};
15
use Innmind\Immutable\{
16
    Sequence,
17
    Stream,
18
    StreamInterface
19
};
20
21
final class Frame
22
{
23
    private $type;
24
    private $channel;
25
    private $method;
26
    private $values;
27
    private $string;
28
29
    public function __construct(
30
        Type $type,
31
        Channel $channel,
32
        Method $method,
33
        Value ...$values
34
    ) {
35
        $this->type = $type;
36
        $this->channel = $channel;
37
        $this->method = $method;
38
        $values = new Sequence(...$values);
39
        $payload = $values->join('')->toEncoding('ASCII');
40
        $frame = new Sequence(
41
            new UnsignedOctet($type->toInt()),
0 ignored issues
show
Documentation introduced by
$type->toInt() is of type integer, but the function expects a object<Innmind\Math\Algebra\Integer>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42
            new UnsignedShortInteger($channel->toInt()),
0 ignored issues
show
Documentation introduced by
$channel->toInt() is of type integer, but the function expects a object<Innmind\Math\Algebra\Integer>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43
            new UnsignedLongInteger(
44
                $payload->length() + 4 // 4 is the size for the method
0 ignored issues
show
Documentation introduced by
$payload->length() + 4 is of type integer, but the function expects a object<Innmind\Math\Algebra\Integer>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
45
            ),
46
            new UnsignedShortInteger($method->class()),
0 ignored issues
show
Documentation introduced by
$method->class() is of type integer, but the function expects a object<Innmind\Math\Algebra\Integer>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
47
            new UnsignedShortInteger($method->method()),
0 ignored issues
show
Documentation introduced by
$method->method() is of type integer, but the function expects a object<Innmind\Math\Algebra\Integer>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
48
            $payload,
49
            new UnsignedOctet(0xCE)
0 ignored issues
show
Documentation introduced by
206 is of type integer, but the function expects a object<Innmind\Math\Algebra\Integer>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
50
        );
51
        $this->values = $values->reduce(
52
            new Stream(Value::class),
53
            static function(Stream $stream, Value $value): Stream {
54
                return $stream->add($value);
1 ignored issue
show
Documentation introduced by
$value is of type object<Innmind\AMQP\Transport\Frame\Value>, but the function expects a object<Innmind\Immutable\T>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
55
            }
56
        );
57
        $this->string = (string) $frame->join('');
58
    }
59
60
    public function type(): Type
61
    {
62
        return $this->type;
63
    }
64
65
    public function channel(): Channel
66
    {
67
        return $this->channel;
68
    }
69
70
    public function method(): Method
71
    {
72
        return $this->method;
73
    }
74
75
    /**
76
     * @return StreamInterface<Value>
0 ignored issues
show
Documentation introduced by
The doc-type StreamInterface<Value> could not be parsed: Expected "|" or "end of type", but got "<" at position 15. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
77
     */
78
    public function values(): StreamInterface
79
    {
80
        return $this->values;
81
    }
82
83
    public function __toString(): string
84
    {
85
        return $this->string;
86
    }
87
}
88