Passed
Pull Request — master (#11)
by Dmitry
01:44
created

Client::pop()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace SymfonyBundles\RedisBundle\Redis;
4
5
class Client extends \Predis\Client implements ClientInterface
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10 1
    public function pop(string $key): ?string
11
    {
12 1
        return $this->call('lpop', [$key]);
13
    }
14
15
    /**
16
     * {@inheritdoc}
17
     */
18 2
    public function push(string $key, ...$values): int
19
    {
20 2
        return $this->call('rpush', array_merge([$key], $values));
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 2
    public function count(string $key): int
27
    {
28 2
        return $this->call('llen', [$key]);
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 2
    public function remove(string $key): int
35
    {
36 2
        return $this->call('del', [$key]);
37
    }
38
39
    /**
40
     * Creates a Redis command with the specified arguments and sends a request to the server.
41
     *
42
     * @param string $command   the command ID
43
     * @param array  $arguments the arguments for the command
44
     *
45
     * @return mixed
46
     */
47 2
    protected function call($command, array $arguments = [])
48
    {
49 2
        return $this->executeCommand($this->createCommand($command, $arguments));
50
    }
51
}
52