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 — master ( fc45f0...dd0edf )
by Baptiste
02:38
created

Purge::__invoke()   A

Complexity

Conditions 2
Paths 5

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 5
nop 3
dl 0
loc 15
ccs 11
cts 11
cp 1
crap 2
rs 9.4285
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
    Model\Queue,
9
    Exception\UnexpectedFrame,
10
};
11
use Innmind\CLI\{
12
    Command,
13
    Command\Arguments,
14
    Command\Options,
15
    Environment,
16
};
17
use Innmind\Immutable\Str;
18
19
final class Purge implements Command
20
{
21
    private $client;
22
23 6
    public function __construct(Client $client)
24
    {
25 6
        $this->client = $client;
26 6
    }
27
28 3
    public function __invoke(Environment $env, Arguments $arguments, Options $options): void
29
    {
30 3
        $queue = $arguments->get('queue');
31
32
        try {
33
            $this
34 3
                ->client
35 3
                ->channel()
36 2
                ->queue()
37 2
                ->purge(new Queue\Purge($queue));
38 2
        } catch (UnexpectedFrame $e) {
39 1
            $env->error()->write(Str::of("Purging \"$queue\" failed"));
40 1
            $env->exit(1);
41 2
        } finally {
42 3
            $this->client->close();
43
        }
44 2
    }
45
46 1
    public function __toString(): string
47
    {
48
        return <<<USAGE
49 1
innmind:amqp:purge queue
50
51
Will delete all messages for the given queue
52
USAGE;
53
    }
54
}
55