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 ( 8fee49...c9e6b0 )
by Clinton
02:56
created

RedisQ::queueObject()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
cc 2
eloc 14
c 3
b 1
f 1
nc 2
nop 1
dl 0
loc 24
rs 8.9713
1
<?php
2
3
namespace RedisQ;
4
5
class RedisQ
6
{
7
    public function queueObject($object)
8
    {
9
        global $redis;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
10
11
        $wrapped = serialize($object);
12
13
        $allQueues = new RedisTtlSortedSet('redisQ:allQueues');
14
	$objectQueues = new RedisTtlSortedSet('objectQueues');
15
        $queues = $allQueues->getMembers();
16
17
        $multi = $redis->multi();
18
19
        // Store an instance of the object
20
        $objectID = 'redisQ:objectID:'.uniqID().md5($wrapped);
21
	$objectQueues->add(time(), $objectID);
22
        $multi->setex($objectID, 9600, $wrapped);
23
24
        // Add objectID to all queues
25
        foreach ($queues as $queueID) {
26
            $multi->lPush($queueID, $objectID);
27
            $multi->expire($queueID, 9600);
28
        }
29
        $multi->exec();
30
    }
31
32
    public function registerListener($queueID)
33
    {
34
        $allQueues = new RedisTtlSortedSet('redisQ:allQueues');
35
        $allQueues->add(time(), $queueID);
36
    }
37
38
    public function listen($queueID)
39
    {
40
        global $redis;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
41
42
        $rQueueID = "redisQ:queueID:$queueID";
43
44
        self::registerListener($rQueueID);
45
46
        $pop = $redis->blPop($rQueueID, 10);
47
        if (!isset($pop[1])) {
48
            return;
49
        }
50
51
        $objectID = $pop[1];
52
        $object = $redis->get($objectID);
53
54
        return unserialize($object);
55
    }
56
}
57