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
Pull Request — master (#320)
by Maksim
03:57
created

InteropDriver::listQueues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
namespace Bernard\Driver;
3
4
use Bernard\Driver;
5
use Interop\Queue\PsrConsumer;
6
use Interop\Queue\PsrContext;
7
8
class InteropDriver implements Driver
9
{
10
    /**
11
     * @var PsrContext
12
     */
13
    private $context;
14
15
    /**
16
     * @var PsrConsumer[]
17
     */
18
    private $consumers;
19
20
    /**
21
     * @param PsrContext $context
22
     */
23
    public function __construct(PsrContext $context)
24
    {
25
        $this->context = $context;
26
27
        $this->consumers = [];
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function listQueues()
34
    {
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function createQueue($queueName)
41
    {
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function countMessages($queueName)
48
    {
49
        return 0;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function pushMessage($queueName, $message)
56
    {
57
        $queue = $this->context->createQueue($queueName);
58
        $message = $this->context->createMessage($message);
59
60
        $this->context->createProducer()->send($queue, $message);
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function popMessage($queueName, $duration = 5)
67
    {
68
        if ($message = $this->getQueueConsumer($queueName)->receive($duration * 1000)) {
69
            return [$message->getBody(), $message];
70
        }
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function acknowledgeMessage($queueName, $receipt)
77
    {
78
        $this->getQueueConsumer($queueName)->acknowledge($receipt);
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function peekQueue($queueName, $index = 0, $limit = 20)
85
    {
86
        return [];
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92
    public function removeQueue($queueName)
93
    {
94
    }
95
96
    /**
97
     * {@inheritdoc}
98
     */
99
    public function info()
100
    {
101
        return [];
102
    }
103
104
    /**
105
     * @param string $queueName
106
     *
107
     * @return PsrConsumer
108
     */
109
    private function getQueueConsumer($queueName)
110
    {
111
        if (false == array_key_exists($queueName, $this->consumers)) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
112
            $queue = $this->context->createQueue($queueName);
113
114
            $this->consumers[$queueName] = $this->context->createConsumer($queue);
115
        }
116
117
        return $this->consumers[$queueName];
118
    }
119
}