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 ( 1144b4...828920 )
by Márk
07:09 queued 04:40
created

Driver   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 0
dl 0
loc 92
rs 10
c 0
b 0
f 0

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
    public function listQueues()
18
    {
19
        return array_keys($this->queues);
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function createQueue($queueName)
26
    {
27
        if (!array_key_exists($queueName, $this->queues)) {
28
            $this->queues[$queueName] = [];
29
        }
30
    }
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