Completed
Pull Request — master (#1)
by Adam
05:22 queued 03:01
created

RedisDriver::pop()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
namespace Equip\Queue\Driver;
4
5
use Redis;
6
7
class RedisDriver implements DriverInterface
8
{
9
    /**
10
     * @var Redis
11
     */
12
    private $redis;
13
14
    /**
15
     * @param Redis $redis
16
     */
17
    public function __construct(Redis $redis)
18
    {
19
        $this->redis = $redis;
20
    }
21
22
    /**
23
     * @inheritdoc
24
     */
25
    public function push($queue, $message)
26
    {
27
        return (bool) $this->redis->rPush($queue, $message);
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public function pop($queue)
34
    {
35
        list($_, $message) = $this->redis->blPop([$queue], 5) ?: null;
1 ignored issue
show
Unused Code introduced by
The assignment to $_ is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
36
37
        return $message;
38
    }
39
}
40