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 ( 052a19...142883 )
by Baptiste
04:15
created

Consume::__invoke()   B

Complexity

Conditions 4
Paths 12

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 14
nc 12
nop 3
dl 0
loc 22
ccs 14
cts 14
cp 1
crap 4
rs 8.9197
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQP\Command;
5
6
use Innmind\AMQP\{
7
    Client,
8
    Consumers,
9
    Model\Basic,
10
    Model\Basic\Qos,
11
};
12
use Innmind\CLI\{
13
    Command,
14
    Command\Arguments,
15
    Command\Options,
16
    Environment,
17
};
18
19
final class Consume implements Command
20
{
21
    private $client;
22
    private $consumers;
23
24 7
    public function __construct(Client $client, Consumers $consumers)
25
    {
26 7
        $this->client = $client;
27 7
        $this->consumers = $consumers;
28 7
    }
29
30 4
    public function __invoke(Environment $env, Arguments $arguments, Options $options): void
31
    {
32 4
        $queue = $arguments->get('queue');
33 4
        $consume = $this->consumers->get($queue);
1 ignored issue
show
Bug introduced by
It seems like $queue can also be of type Innmind\Immutable\StreamInterface; however, parameter $queue of Innmind\AMQP\Consumers::get() does only seem to accept string, 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

33
        $consume = $this->consumers->get(/** @scrutinizer ignore-type */ $queue);
Loading history...
34 4
        $basic = $this->client->channel()->basic();
35
36 4
        if ($arguments->contains('prefetch')) {
37 1
            $basic->qos(new Qos(0, (int) $arguments->get('prefetch')));
38 3
        } else if ($arguments->contains('number')) {
39 1
            $basic->qos(new Qos(0, (int) $arguments->get('number')));
40
        }
41
42 4
        $consumer = $basic->consume(new Basic\Consume($queue));
1 ignored issue
show
Bug introduced by
It seems like $queue can also be of type Innmind\Immutable\StreamInterface; however, parameter $queue of Innmind\AMQP\Model\Basic\Consume::__construct() does only seem to accept string, 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

42
        $consumer = $basic->consume(new Basic\Consume(/** @scrutinizer ignore-type */ $queue));
Loading history...
43
44 4
        if ($arguments->contains('number')) {
45 2
            $consumer->take((int) $arguments->get('number'));
46
        }
47
48
        try {
49 4
            $consumer->foreach($consume);
50 3
        } finally {
51 4
            $this->client->close();
52
        }
53 3
    }
54
55 1
    public function __toString(): string
56
    {
57
        return <<<USAGE
58 1
innmind:amqp:consume queue [number] [prefetch]
59
60
Will process messages from the given queue
61
USAGE;
62
    }
63
}
64