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.

Driver   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 14.58%

Importance

Changes 0
Metric Value
wmc 15
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 92
ccs 7
cts 48
cp 0.1458
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A listQueues() 0 4 1
A createQueue() 0 6 2
A countMessages() 0 8 2
A pushMessage() 0 4 1
A popMessage() 0 8 3
A acknowledgeMessage() 0 4 1
A peekQueue() 0 8 2
A removeQueue() 0 6 2
A info() 0 4 1
1
<?php
2
3
namespace Bernard\Driver\InMemory;
4
5
/**
6
 * Simple in-memory driver.
7
 *
8
 * @author Márk Sági-Kazár <[email protected]>
9
 */
10
final class Driver implements \Bernard\Driver
11
{
12
    private $queues = [];
13
14
    /**
15
     * {@inheritdoc}
16
     */
17 1
    public function listQueues()
18
    {
19 1
        return array_keys($this->queues);
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 1
    public function createQueue($queueName)
26
    {
27 1
        if (!array_key_exists($queueName, $this->queues)) {
28 1
            $this->queues[$queueName] = [];
29 1
        }
30 1
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function countMessages($queueName)
36
    {
37
        if (array_key_exists($queueName, $this->queues)) {
38
            return count($this->queues[$queueName]);
39
        }
40
41
        return 0;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function pushMessage($queueName, $message)
48
    {
49
        $this->queues[$queueName][] = $message;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function popMessage($queueName, $duration = 5)
56
    {
57
        if (!array_key_exists($queueName, $this->queues) || count($this->queues[$queueName]) < 1) {
58
            return [null, null];
59
        }
60
61
        return [array_shift($this->queues[$queueName]), null];
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function acknowledgeMessage($queueName, $receipt)
68
    {
69
        // Noop
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function peekQueue($queueName, $index = 0, $limit = 20)
76
    {
77
        if (array_key_exists($queueName, $this->queues)) {
78
            return array_slice($this->queues[$queueName], $index, $limit);
79
        }
80
81
        return null;
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function removeQueue($queueName)
88
    {
89
        if (array_key_exists($queueName, $this->queues)) {
90
            unset($this->queues[$queueName]);
91
        }
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97
    public function info()
98
    {
99
        return [];
100
    }
101
}
102