Passed
Push — master ( c574e8...34a0e7 )
by Dmitry
48s
created

Client::call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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
nc 1
nop 2
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 4
    public function __construct($parameters = null, $options = null)
11
    {
12 4
        if (\count($parameters) === 1) {
13 1
            $parameters = \array_shift($parameters);
14
        }
15
16 4
        parent::__construct($parameters, $options);
17 4
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 1
    public function pop(string $key): ?string
23
    {
24 1
        return $this->call('lpop', [$key]);
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 2
    public function push(string $key, ...$values): int
31
    {
32 2
        return $this->call('rpush', array_merge([$key], $values));
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 2
    public function count(string $key): int
39
    {
40 2
        return $this->call('llen', [$key]);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 2
    public function remove(string $key): int
47
    {
48 2
        return $this->call('del', [$key]);
49
    }
50
51
    /**
52
     * Creates a Redis command with the specified arguments and sends a request to the server.
53
     *
54
     * @param string $command   the command ID
55
     * @param array  $arguments the arguments for the command
56
     *
57
     * @return mixed
58
     */
59 2
    protected function call($command, array $arguments = [])
60
    {
61 2
        return $this->executeCommand($this->createCommand($command, $arguments));
62
    }
63
}
64