Completed
Pull Request — master (#14)
by Dmitry
06:16
created

Client   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 59
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A pop() 0 4 1
A push() 0 4 1
A count() 0 4 1
A remove() 0 4 1
A call() 0 4 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