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
04:24
created

InteropDriver::acknowledgeMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
namespace Bernard\Driver;
3
4
use Bernard\Driver;
5
use Interop\Queue\PsrConsumer;
6
use Interop\Queue\PsrContext;
7
8
final 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
        return [];
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function createQueue($queueName)
42
    {
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function countMessages($queueName)
49
    {
50
        return 0;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function pushMessage($queueName, $message)
57
    {
58
        $queue = $this->context->createQueue($queueName);
59
        $message = $this->context->createMessage($message);
60
61
        $this->context->createProducer()->send($queue, $message);
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function popMessage($queueName, $duration = 5)
68
    {
69
        if ($message = $this->getQueueConsumer($queueName)->receive($duration * 1000)) {
70
            return [$message->getBody(), $message];
71
        }
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function acknowledgeMessage($queueName, $receipt)
78
    {
79
        $this->getQueueConsumer($queueName)->acknowledge($receipt);
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function peekQueue($queueName, $index = 0, $limit = 20)
86
    {
87
        return [];
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    public function removeQueue($queueName)
94
    {
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function info()
101
    {
102
        return [];
103
    }
104
105
    /**
106
     * @param string $queueName
107
     *
108
     * @return PsrConsumer
109
     */
110
    private function getQueueConsumer($queueName)
111
    {
112
        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...
113
            $queue = $this->context->createQueue($queueName);
114
115
            $this->consumers[$queueName] = $this->context->createConsumer($queue);
116
        }
117
118
        return $this->consumers[$queueName];
119
    }
120
121
    /**
122
     * @return PsrContext
123
     */
124
    public function getContext()
125
    {
126
        return $this->context;
127
    }
128
}
129