Total Complexity | 8 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 (is_array($parameters) && \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 mixed[] $arguments the arguments for the command |
||
56 | * |
||
57 | * @return mixed |
||
58 | */ |
||
59 | 2 | protected function call(string $command, array $arguments = []) |
|
62 | } |
||
63 | } |
||
64 |