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 11

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 55.56%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 91
ccs 25
cts 45
cp 0.5556
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A listQueues() 0 4 1
A createQueue() 0 3 1
A countMessages() 0 6 1
A pushMessage() 0 4 1
A popMessage() 0 8 2
A acknowledgeMessage() 0 4 1
A peekQueue() 0 4 1
A removeQueue() 0 3 1
A info() 0 7 1
1
<?php
2
3
namespace Bernard\Driver\Pheanstalk;
4
5
use Pheanstalk\PheanstalkInterface;
6
7
/**
8
 * Implements a Driver for use with https://github.com/pda/pheanstalk.
9
 */
10
final class Driver implements \Bernard\Driver
11
{
12
    private $pheanstalk;
13
14
    /**
15
     * @param PheanstalkInterface $pheanstalk
16
     */
17 8
    public function __construct(PheanstalkInterface $pheanstalk)
18
    {
19 8
        $this->pheanstalk = $pheanstalk;
20 8
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 1
    public function listQueues()
26
    {
27 1
        return $this->pheanstalk->listTubes();
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function createQueue($queueName)
34
    {
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function countMessages($queueName)
41
    {
42 1
        $stats = $this->pheanstalk->statsTube($queueName);
43
44 1
        return $stats['current-jobs-ready'];
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 1
    public function pushMessage($queueName, $message)
51
    {
52 1
        $this->pheanstalk->putInTube($queueName, $message);
53 1
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 1
    public function popMessage($queueName, $duration = 5)
59
    {
60 1
        if ($job = $this->pheanstalk->reserveFromTube($queueName, $duration)) {
61 1
            return [$job->getData(), $job];
62
        }
63
64 1
        return [null, null];
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70 1
    public function acknowledgeMessage($queueName, $receipt)
71
    {
72 1
        $this->pheanstalk->delete($receipt);
73 1
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78 1
    public function peekQueue($queueName, $index = 0, $limit = 20)
79
    {
80 1
        return [];
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function removeQueue($queueName)
87
    {
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93 1
    public function info()
94
    {
95 1
        return $this->pheanstalk
96 1
            ->stats()
97 1
            ->getArrayCopy()
98 1
        ;
99
    }
100
}
101