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 11

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 1
dl 0
loc 91
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
 * @package Bernard
11
 */
12
final class Driver implements \Bernard\Driver
13
{
14
    private $pheanstalk;
15
16
    /**
17
     * @param PheanstalkInterface $pheanstalk
18
     */
19
    public function __construct(PheanstalkInterface $pheanstalk)
20
    {
21
        $this->pheanstalk = $pheanstalk;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function listQueues()
28
    {
29
        return $this->pheanstalk->listTubes();
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function createQueue($queueName)
36
    {
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function countMessages($queueName)
43
    {
44
        $stats = $this->pheanstalk->statsTube($queueName);
45
46
        return $stats['current-jobs-ready'];
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function pushMessage($queueName, $message)
53
    {
54
        $this->pheanstalk->putInTube($queueName, $message);
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function popMessage($queueName, $duration = 5)
61
    {
62
        if ($job = $this->pheanstalk->reserveFromTube($queueName, $duration)) {
63
            return [$job->getData(), $job];
64
        }
65
66
        return array(null, null);
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function acknowledgeMessage($queueName, $receipt)
73
    {
74
        $this->pheanstalk->delete($receipt);
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function peekQueue($queueName, $index = 0, $limit = 20)
81
    {
82
        return [];
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function removeQueue($queueName)
89
    {
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95
    public function info()
96
    {
97
        return $this->pheanstalk
98
            ->stats()
99
            ->getArrayCopy()
100
        ;
101
    }
102
}
103