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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 2
A __toString() 0 3 1
A __construct() 0 3 1
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