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 (#206)
by Jeroen
02:07
created

PheanstalkDriver   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 111
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 13
Bugs 1 Features 3
Metric Value
wmc 12
c 13
b 1
f 3
lcom 1
cbo 3
dl 0
loc 111
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A listQueues() 0 4 1
A createQueue() 0 3 1
A acknowledgeMessage() 0 4 1
A peekQueue() 0 4 1
A removeQueue() 0 3 1
A countMessages() 0 6 1
A pushMessage() 0 12 1
A popMessage() 0 8 2
A info() 0 7 1
A configurePushOptions() 0 8 1
1
<?php
2
3
namespace Bernard\Driver;
4
5
use Pheanstalk\PheanstalkInterface;
6
use Symfony\Component\OptionsResolver\OptionsResolver;
7
8
/**
9
 * Implements a Driver for use with https://github.com/pda/pheanstalk
10
 *
11
 * @package Bernard
12
 */
13
class PheanstalkDriver extends AbstractDriver
14
{
15
    protected $pheanstalk;
16
17
    /**
18
     * @param PheanstalkInterface $pheanstalk
19
     */
20
    public function __construct(PheanstalkInterface $pheanstalk)
21
    {
22
        $this->pheanstalk = $pheanstalk;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function listQueues()
29
    {
30
        return $this->pheanstalk->listTubes();
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function createQueue($queueName, array $options = [])
37
    {
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function countMessages($queueName)
44
    {
45
        $stats = $this->pheanstalk->statsTube($queueName);
46
47
        return $stats['current-jobs-ready'];
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function pushMessage($queueName, $message, array $options = [])
54
    {
55
        $options = $this->validatePushOptions($options);
56
57
        $this->pheanstalk->putInTube(
58
            $queueName,
59
            $message,
60
            $options['priority'],
61
            $options['delay'],
62
            $options['ttr']
63
        );
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function popMessage($queueName, $duration = 5)
70
    {
71
        if ($job = $this->pheanstalk->reserveFromTube($queueName, $duration)) {
72
            return [$job->getData(), $job];
73
        }
74
75
        return array(null, null);
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function acknowledgeMessage($queueName, $receipt)
82
    {
83
        $this->pheanstalk->delete($receipt);
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function peekQueue($queueName, $index = 0, $limit = 20)
90
    {
91
        return [];
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97
    public function removeQueue($queueName)
98
    {
99
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104
    public function info()
105
    {
106
        return $this->pheanstalk
107
            ->stats()
108
            ->getArrayCopy()
109
        ;
110
    }
111
112
    /**
113
     * {@inheritdoc}
114
     */
115
    public function configurePushOptions(OptionsResolver $resolver)
116
    {
117
        $resolver->setDefaults(array(
118
            'priority' => PheanstalkInterface::DEFAULT_PRIORITY,
119
            'delay' => PheanstalkInterface::DEFAULT_DELAY,
120
            'ttr' => PheanstalkInterface::DEFAULT_TTR,
121
        ));
122
    }
123
}
124