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 ( e71353...ee213a )
by Baptiste
01:44
created

Delegate   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 14
c 0
b 0
f 0
lcom 1
cbo 4
dl 0
loc 93
ccs 27
cts 36
cp 0.75
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A version() 0 4 1
A use() 0 22 3
A read() 0 4 1
A readHeader() 0 4 1
A method() 0 4 1
A connection() 0 4 1
A channel() 0 4 1
A exchange() 0 4 1
A queue() 0 4 1
A basic() 0 4 1
A transaction() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Transport\Protocol;
5
6
use Innmind\AMQP\{
7
    Transport\Protocol,
8
    Transport\Frame\Method,
9
    Exception\VersionNotUsable
10
};
11
use Innmind\Immutable\{
12
    Sequence,
13
    Str,
14
    StreamInterface
15
};
16
17
final class Delegate implements Protocol
18
{
19
    private $protocols;
20
    private $inUse;
21
22
    public function __construct(Protocol $first, Protocol ...$protocols)
23
    {
24 4
        $protocols = (new Sequence($first, ...$protocols))->sort(static function(Protocol $a, Protocol $b): bool {
25 3
            return $b->version()->higherThan($a->version());
0 ignored issues
show
Documentation introduced by
$a->version() is of type object<Innmind\AMQP\Transport\Protocol\Version>, but the function expects a object<self>.

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...
26 4
        });
27 4
        $this->inUse = $protocols->first();
28 4
        $this->protocols = $protocols;
29 4
    }
30
31 3
    public function version(): Version
32
    {
33 3
        return $this->inUse->version();
34
    }
35
36 2
    public function use(Version $version): Protocol
37
    {
38
        $protocols = $this
39 2
            ->protocols
40 2
            ->filter(static function(Protocol $protocol) use ($version): bool {
41
                try {
42 2
                    $protocol->use($version);
43
44 2
                    return true;
45 2
                } catch (VersionNotUsable $e) {
46 2
                    return false;
47
                }
48 2
            });
49
50 2
        if ($protocols->size() === 0) {
51
            throw new VersionNotUsable($version);
52
        }
53
54 2
        $this->inUse = $protocols->first();
55
56 2
        return $this;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 1
    public function read(Method $method, Str $arguments): StreamInterface
63
    {
64 1
        return $this->inUse->read($method, $arguments);
65
    }
66
67 1
    /**
68
     * {@inheritdoc}
69 1
     */
70
    public function readHeader(Str $arguments): StreamInterface
71
    {
72 1
        return $this->inUse->readHeader($arguments);
73
    }
74 1
75
    public function method(string $name): Method
76
    {
77 1
        return $this->inUse->method($name);
78
    }
79 1
80
    public function connection(): Connection
81
    {
82
        return $this->inUse->connection();
83
    }
84
85
    public function channel(): Channel
86
    {
87
        return $this->inUse->channel();
88
    }
89
90
    public function exchange(): Exchange
91
    {
92
        return $this->inUse->exchange();
93
    }
94
95
    public function queue(): Queue
96
    {
97
        return $this->inUse->queue();
98
    }
99
100
    public function basic(): Basic
101
    {
102
        return $this->inUse->basic();
103
    }
104
105
    public function transaction(): Transaction
106
    {
107
        return $this->inUse->transaction();
108
    }
109
}
110