Completed
Push — master ( 52cc4c...9e125a )
by Kamil
11s
created

Redis::isBusy()   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 0
crap 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 25 and the first side effect is on line 1881.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Dazzle\Redis;
4
5
use Clue\Redis\Protocol\Model\ErrorReply;
6
use Clue\Redis\Protocol\Model\ModelInterface;
7
use Clue\Redis\Protocol\Parser\ParserException;
8
use Dazzle\Event\BaseEventEmitter;
9
use Dazzle\Loop\LoopAwareTrait;
10
use Dazzle\Loop\LoopInterface;
11
use Dazzle\Promise\Deferred;
12
use Dazzle\Promise\PromiseInterface;
13
use Dazzle\Redis\Command\Enum;
14
use Dazzle\Redis\Driver\Request;
15
use Dazzle\Redis\Driver\Driver;
16
use Dazzle\Redis\Driver\DriverInterface;
17
use Dazzle\Redis\Command\Builder;
18
use Dazzle\Socket\Socket;
19
use Dazzle\Socket\SocketInterface;
20
use Dazzle\Throwable\Exception\Runtime\ExecutionException;
21
use Dazzle\Throwable\Exception\Runtime\UnderflowException;
22
use Error;
23
use Exception;
24
25
class Redis extends BaseEventEmitter implements RedisInterface
26
{
27
    use LoopAwareTrait;
28
29
    /**
30
     * @var string
31
     */
32
    protected $endpoint;
33
34
    /**
35
     * @var SocketInterface
36
     */
37
    protected $stream;
38
39
    /**
40
     * @var DriverInterface
41
     */
42
    protected $driver;
43
44
    /**
45
     * @var bool
46
     */
47
    protected $isConnected;
48
49
    /**
50
     * @var bool
51
     */
52
    protected $isBeingDisconnected;
53
54
    /**
55
     * @var array
56
     */
57
    private $reqs;
58
59
    /**
60
     * @param string $endpoint
61
     * @param LoopInterface $loop
62
     */
63
    public function __construct($endpoint, LoopInterface $loop)
64
    {
65
        $this->endpoint = $endpoint;
66
        $this->loop = $loop;
67
        $this->stream = null;
68
        $this->driver = new Driver();
69
70
        $this->isConnected = false;
71
        $this->isBeingDisconnected = false;
72
73
        $this->reqs = [];
74
    }
75
76
    /**
77
     *
78
     */
79
    public function __destruct()
80
    {
81
        $this->stop();
82
    }
83
84
    /**
85
     * @override
86
     * @inheritDoc
87
     */
88 1
    public function isStarted()
89
    {
90 1
        return $this->isConnected;
91
    }
92
93
    /**
94
     * @override
95
     * @inheritDoc
96
     */
97 1
    public function isBusy()
98
    {
99 1
        return !empty($this->reqs);
100
    }
101
102
    /**
103
     * @override
104
     * @inheritDoc
105
     */
106 1
    public function start()
107
    {
108 1
        if ($this->isStarted())
109
        {
110
            return false;
111
        }
112
113 1
        $ex = null;
114 1
        $stream = null;
115
116
        try
117
        {
118 1
            $stream = $this->createClient($this->endpoint);
119
        }
120
        catch (Error $ex)
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
121
        {}
122
        catch (Exception $ex)
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
123
        {}
124
125 1
        if ($ex !== null)
126
        {
127
            return false;
128
        }
129
130 1
        $this->isConnected = true;
131 1
        $this->isBeingDisconnected = false;
132 1
        $this->stream = $stream;
133
134
        // TODO patch missing pub/sub, pipeline, auth
135 1
        $this->handleStart();
136 1
        $this->emit('start', [ $this ]);
137
138 1
        return true;
139
    }
140
141
    /**
142
     * @override
143
     * @inheritDoc
144
     */
145 1
    public function stop()
146
    {
147 1
        if (!$this->isStarted())
148
        {
149 1
            return false;
150
        }
151
152 1
        $this->isBeingDisconnected = true;
153 1
        $this->isConnected = false;
154
155 1
        $this->stream->close();
156 1
        $this->stream = null;
157
158 1
        foreach ($this->reqs as $req)
159
        {
160
            $req->reject(new ExecutionException('Connection has been closed!'));
161
        }
162
163 1
        $this->reqs = [];
164
165
         // TODO patch missing pub/sub, pipeline, auth
166 1
        $this->handleStop();
167 1
        $this->emit('stop', [ $this ]);
168
169 1
        return true;
170
    }
171
172
    /**
173
     * @override
174
     * @inheritDoc
175
     */
176
    public function end()
177
    {
178
        if (!$this->isStarted() || $this->isBeingDisconnected)
179
        {
180
            return false;
181
        }
182
183
        $this->isBeingDisconnected = true;
184
185
        return true;
186
    }
187
188
    /**
189
     * Dispatch Redis request.
190
     *
191
     * @param Request $command
192
     * @return PromiseInterface
193
     */
194 1
    protected function dispatch(Request $command)
195
    {
196 1
        $request = new Deferred();
197 1
        $promise = $request->getPromise();
198
199 1
        if ($this->isBeingDisconnected)
200
        {
201
            $request->reject(new ExecutionException('Redis client connection is being stopped now.'));
202
        }
203
        else
204
        {
205 1
            $this->stream->write($this->driver->commands($command));
206 1
            $this->reqs[] = $request;
207
        }
208
209 1
        return $promise;
210
    }
211
212
    /**
213
     * @internal
214
     */
215 1 View Code Duplication
    protected function handleStart()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
216
    {
217 1
        if ($this->stream !== null)
218
        {
219 1
            $this->stream->on('data', [ $this, 'handleData' ]);
220 1
            $this->stream->on('close', [ $this, 'stop' ]);
221
        }
222 1
    }
223
224
    /**
225
     * @internal
226
     */
227 1 View Code Duplication
    protected function handleStop()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
228
    {
229 1
        if ($this->stream !== null)
230
        {
231
            $this->stream->removeListener('data', [ $this, 'handleData' ]);
232
            $this->stream->removeListener('close', [ $this, 'stop' ]);
233
        }
234 1
    }
235
236
    /**
237
     * @internal
238
     * @param SocketInterface $stream
239
     * @param string $chunk
240
     */
241 1
    public function handleData($stream, $chunk)
242
    {
243
        try
244
        {
245 1
            $models = $this->driver->parseResponse($chunk);
246
        }
247
        catch (ParserException $error)
248
        {
249
            $this->emit('error', [ $this, $error ]);
250
            $this->stop();
251
            return;
252
        }
253
254 1
        foreach ($models as $data)
255
        {
256
            try
257
            {
258 1
                $this->handleMessage($data);
259
            }
260
            catch (UnderflowException $error)
261
            {
262
                $this->emit('error', [ $this, $error ]);
263
                $this->stop();
264
                return;
265
            }
266
        }
267 1
    }
268
269
    /**
270
     * @internal
271
     * @param ModelInterface $message
272
     */
273 1
    protected function handleMessage(ModelInterface $message)
274
    {
275 1
        if (!$this->reqs)
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->reqs of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
276
        {
277
            throw new UnderflowException('Unexpected reply received, no matching request found');
278
        }
279
280 1
        $request = array_shift($this->reqs);
281
282 1
        if ($message instanceof ErrorReply)
283
        {
284
            $request->reject($message);
285
        }
286
        else
287
        {
288 1
            $request->resolve($message->getValueNative());
289
        }
290
291 1
        if ($this->isBeingDisconnected && !$this->isBusy())
292
        {
293 1
            $this->stop();
294
        }
295 1
    }
296
297
    /**
298
     * Create socket client with connection to Redis database.
299
     *
300
     * @param string $endpoint
301
     * @return SocketInterface
302
     * @throws ExecutionException
303
     */
304 1
    protected function createClient($endpoint)
305
    {
306 1
        $ex = null;
307
308
        try
309
        {
310 1
            return new Socket($endpoint, $this->loop);
0 ignored issues
show
Bug introduced by
It seems like $this->loop can be null; however, __construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
311
        }
312
        catch (Error $ex)
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
313
        {}
314
        catch (Exception $ex)
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
315
        {}
316
317
        throw new ExecutionException('Redis connection socket could not be created!', 0, $ex);
318
    }
319
320
    public function auth($password)
321
    {
322
        $command = Enum::AUTH;
323
        $args = [$password];
324
325
        return $this->dispatch(Builder::build($command, $args));
326
    }
327
328
    public function append($key, $value)
329
    {
330
        $command = Enum::APPEND;
331
        $args = [$key, $value];
332
333
        return $this->dispatch(Builder::build($command, $args));
334
    }
335
336
    public function bgRewriteAoF()
337
    {
338
        $command = Enum::BGREWRITEAOF;
339
340
        return $this->dispatch(Builder::build($command));
341
    }
342
343
    public function bgSave()
344
    {
345
        $command = Enum::BGSAVE;
346
347
        return $this->dispatch(Builder::build($command));
348
    }
349
350
    public function bitCount($key, $start = 0, $end = 0)
351
    {
352
        $command = Enum::BITCOUNT;
353
        $args = [$key, $start, $end];
354
355
        return $this->dispatch(Builder::build($command, $args));
356
    }
357
358
    public function bitField($key, $subCommand = null, ...$param)
359
    {
360
        $command = Enum::BITFIELD;
361
        switch ($subCommand = strtoupper($subCommand)) {
362 View Code Duplication
            case 'GET' : {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
363
                list ($type, $offset) = $param;
364
                $args = [$subCommand, $type, $offset];
365
                break;
366
            }
367 View Code Duplication
            case 'SET' : {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
368
                list ($type, $offset, $value) = $param;
369
                $args = [$subCommand, $type, $offset, $value];
370
                break;
371
            }
372
            case 'INCRBY' : {
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
373
                list ($type, $offset, $increment) = $param;
374
                $args = [$type, $offset, $increment];
375
                break;
376
            }
377
            case 'OVERFLOW' : {
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
378
                list ($behavior) = $param;
379
                $args = [$subCommand, $behavior];
380
                break;
381
            }
382
            default : {
0 ignored issues
show
Coding Style introduced by
DEFAULT statements must be defined using a colon

As per the PSR-2 coding standard, default statements should not be wrapped in curly braces.

switch ($expr) {
    default: { //wrong
        doSomething();
        break;
    }
}

switch ($expr) {
    default: //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
383
                    $args = [];
384
                    break;
385
            }
386
        }
387
        $args = array_filter($args);
388
389
        return $this->dispatch(Builder::build($command, $args));
390
    }
391
392
    public function bitOp($operation, $dstKey, $srcKey, ...$keys)
393
    {
394
        $command = Enum::BITOP;
395
        $args = [$operation, $dstKey, $srcKey];
396
        $args = array_merge($args, $keys);
397
398
        return $this->dispatch(Builder::build($command, $args));
399
    }
400
401
    public function bitPos($key, $bit, $start = 0, $end = 0)
402
    {
403
        $command = Enum::BITPOS;
404
        $args = [$key, $bit, $start, $end];
405
406
        return $this->dispatch(Builder::build($command, $args));
407
    }
408
409 View Code Duplication
    public function blPop(array $keys, $timeout)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
410
    {
411
        // TODO: Implement blPop() method.
412
        $command = Enum::BLPOP;
413
        $keys[] = $timeout;
414
        $args = $keys;
415
        $promise = $this->dispatch(Builder::build($command, $args));
416
        $promise = $promise->then(function ($value) {
417
            if (is_array($value)) {
418
                list($k,$v) = $value;
419
420
                return [
421
                    'key'=>$k,
422
                    'value'=>$v
423
                ];
424
            }
425
426
            return $value;
427
        });
428
429
        return $promise;
430
    }
431
432 View Code Duplication
    public function brPop(array $keys, $timeout)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
433
    {
434
        // TODO: Implement brPop() method.
435
        $command = Enum::BRPOP;
436
        $keys[] = $timeout;
437
        $args = $keys;
438
        $promise = $this->dispatch(Builder::build($command, $args));
439
        $promise = $promise->then(function ($value) {
440
            if (is_array($value)) {
441
                list($k,$v) = $value;
442
443
                return [
444
                    'key'=>$k,
445
                    'value'=>$v
446
                ];
447
            }
448
449
            return $value;
450
        });
451
452
        return $promise;
453
    }
454
455
    public function brPopLPush($src, $dst, $timeout)
456
    {
457
        // TODO: Implement brPopLPush() method.
458
        $command = Enum::BRPOPLPUSH;
459
        $args = [$src, $dst, $timeout];
460
461
        return $this->dispatch(Builder::build($command, $args));
462
    }
463
464 View Code Duplication
    public function decr($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
465
    {
466
        // TODO: Implement decr() method.
467
        $command = Enum::DECR;
468
        $args = [$key];
469
470
        return $this->dispatch(Builder::build($command, $args));
471
    }
472
473
    public function decrBy($key, $decrement)
474
    {
475
        // TODO: Implement decrBy() method.
476
        $command = Enum::DECRBY;
477
        $args = [$key, $decrement];
478
479
        return $this->dispatch(Builder::build($command, $args));
480
    }
481
482 View Code Duplication
    public function del($key,...$keys)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
483
    {
484
        $command = Enum::DEL;
485
        $keys[] = $key;
486
        $args = $keys;
487
488
        return $this->dispatch(Builder::build($command, $args));
489
    }
490
491
    public function discard()
492
    {
493
        // TODO: Implement discard() method.
494
        $command = Enum::DISCARD;
495
496
        return $this->dispatch(Builder::build($command));
497
    }
498
499 View Code Duplication
    public function dump($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
500
    {
501
        // TODO: Implement dump() method.
502
        $command = Enum::DUMP;
503
        $args = [$key];
504
505
        return $this->dispatch(Builder::build($command, $args));
506
    }
507
508
    public function exists($key, ...$keys)
509
    {
510
        // TODO: Implement exists() method.
511
        $command = Enum::EXISTS;
512
        $args = [$key];
513
        $args = array_merge($args, $keys);
514
515
        return $this->dispatch(Builder::build($command, $args));
516
    }
517
518
    public function expire($key, $seconds)
519
    {
520
        // TODO: Implement expire() method.
521
        $command = Enum::EXPIRE;
522
        $args = [$key, $seconds];
523
524
        return $this->dispatch(Builder::build($command, $args));
525
    }
526
527
    public function expireAt($key, $timestamp)
528
    {
529
        // TODO: Implement expireAt() method.
530
        $command = Enum::EXPIREAT;
531
        $args = [$key, $timestamp];
532
533
        return $this->dispatch(Builder::build($command, $args));
534
    }
535
536 1 View Code Duplication
    public function get($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
537
    {
538 1
        $command = Enum::GET;
539 1
        $args = [$key];
540
541 1
        return $this->dispatch(Builder::build($command, $args));
542
    }
543
544
    public function getBit($key, $offset)
545
    {
546
        // TODO: Implement getBit() method.
547
        $command = Enum::GETBIT;
548
        $args = [$key, $offset];
549
550
        return $this->dispatch(Builder::build($command, $args));
551
    }
552
553
    public function getRange($key, $start, $end)
554
    {
555
        // TODO: Implement getRange() method.
556
        $command = Enum::GETRANGE;
557
        $args = [$key, $start, $end];
558
559
        return $this->dispatch(Builder::build($command, $args));
560
    }
561
562
    public function getSet($key, $value)
563
    {
564
        // TODO: Implement getSet() method.
565
        $command = Enum::GETSET;
566
        $args = [$key, $value];
567
568
        return $this->dispatch(Builder::build($command, $args));
569
    }
570
571 View Code Duplication
    public function incr($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
572
    {
573
        $command = Enum::INCR;
574
        $args = [$key];
575
576
        return $this->dispatch(Builder::build($command, $args));
577
    }
578
579
    public function incrBy($key, $increment)
580
    {
581
        // TODO: Implement incrBy() method.
582
        $command = Enum::INCRBY;
583
        $args = [$key, $increment];
584
585
        return $this->dispatch(Builder::build($command, $args));
586
    }
587
588
    public function incrByFloat($key, $increment)
589
    {
590
        // TODO: Implement incrByFloat() method.
591
        $command = Enum::INCRBYFLOAT;
592
        $args = [$key, $increment];
593
594
        return $this->dispatch(Builder::build($command, $args));
595
    }
596
597
    public function multi()
598
    {
599
        // TODO: Implement multi() method.
600
        $command = Enum::MULTI;
601
602
        return $this->dispatch(Builder::build($command));
603
    }
604
605 View Code Duplication
    public function persist($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
606
    {
607
        $command = Enum::PERSIST;
608
        $args = [$key];
609
610
        return $this->dispatch(Builder::build($command, $args));
611
    }
612
613
    public function pExpire($key, $milliseconds)
614
    {
615
        // TODO: Implement pExpire() method.
616
        $command = Enum::PEXPIRE;
617
        $args = [$key, $milliseconds];
618
619
        return $this->dispatch(Builder::build($command, $args));
620
    }
621
622
    public function pExpireAt($key, $milliseconds)
623
    {
624
        // TODO: Implement pExpireAt() method.
625
        $command = Enum::PEXPIREAT;
626
        $args = [$key, $milliseconds];
627
628
        return $this->dispatch(Builder::build($command, $args));
629
    }
630
631
    public function sync()
632
    {
633
        // TODO: Implement sync() method.
634
        $command = Enum::SYNC;
635
636
        return $this->dispatch(Builder::build($command));
637
    }
638
639
    public function time()
640
    {
641
        // TODO: Implement time() method.
642
        $command = Enum::TIME;
643
644
        return $this->dispatch(Builder::build($command));
645
    }
646
647
    public function touch($key, ...$keys)
648
    {
649
        $command = Enum::TOUCH;
650
        $args = [$key];
651
        $args = array_merge($args, $keys);
652
653
        return $this->dispatch(Builder::build($command, $args));
654
    }
655
656 View Code Duplication
    public function ttl($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
657
    {
658
        // TODO: Implement ttl() method.
659
        $command = Enum::TTL;
660
        $args = [$key];
661
662
        return $this->dispatch(Builder::build($command, $args));
663
    }
664
665 View Code Duplication
    public function type($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
666
    {
667
        $command = Enum::TYPE;
668
        $args = [$key];
669
670
        return $this->dispatch(Builder::build($command, $args));
671
    }
672
673
    public function unLink($key, ...$keys)
674
    {
675
        $command = Enum::UNLINK;
676
        $args = [$key];
677
        $args = array_merge($args, $keys);
678
679
        return $this->dispatch(Builder::build($command, $args));
680
    }
681
682
    public function unWatch()
683
    {
684
        // TODO: Implement unWatch() method.
685
        $command = Enum::UNWATCH;
686
687
        return $this->dispatch(Builder::build($command));
688
    }
689
690
    public function wait($numSlaves, $timeout)
691
    {
692
        // TODO: Implement wait() method.
693
        $command = Enum::WAIT;
694
        $args = [$numSlaves, $timeout];
695
696
        return $this->dispatch(Builder::build($command, $args));
697
    }
698
699
    public function watch($key, ...$keys)
700
    {
701
        // TODO: Implement watch() method.
702
        $command = Enum::WATCH;
703
        $args = [$key];
704
        $args = array_merge($args, $keys);
705
706
        return $this->dispatch(Builder::build($command, $args));
707
    }
708
709
    public function select($index)
710
    {
711
        // TODO: Implement select() method.
712
        $command = Enum::SELECT;
0 ignored issues
show
Unused Code introduced by
$command is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
713
714
        return $this;
715
    }
716
717 1
    public function set($key, $value, array $options = [])
718
    {
719 1
        $command = Enum::SET;
720 1
        array_unshift($options, $key, $value);
721 1
        $args = $options;
722
723 1
        return $this->dispatch(Builder::build($command, $args));
724
    }
725
726
    public function setBit($key, $offset, $value)
727
    {
728
        // TODO: Implement setBit() method.
729
        $command = Enum::SETBIT;
730
        $args = [$key, $offset, $value];
731
732
        return $this->dispatch(Builder::build($command, $args));
733
    }
734
735
    public function setEx($key, $seconds, $value)
736
    {
737
        $command = Enum::SETEX;
738
        $args = [$key, $seconds, $value];
739
740
        return $this->dispatch(Builder::build($command, $args));
741
    }
742
743
    public function setNx($key, $value)
744
    {
745
        $command = Enum::SETNX;
746
        $args = [$key, $value];
747
748
        return $this->dispatch(Builder::build($command, $args));
749
    }
750
751
    public function randomKey()
752
    {
753
        // TODO: Implement randomKey() method.
754
        $command = Enum::RANDOMKEY;
755
756
        return $this->dispatch(Builder::build($command));
757
    }
758
759
    public function readOnly()
760
    {
761
        // TODO: Implement readOnly() method.
762
        $command = Enum::READONLY;
763
764
        return $this->dispatch(Builder::build($command));
765
    }
766
767
    public function rename($key, $newKey)
768
    {
769
        $command = Enum::RENAME;
770
        $args = [$key, $newKey];
771
772
        return $this->dispatch(Builder::build($command, $args));
773
    }
774
775
    public function renameNx($key, $newKey)
776
    {
777
        $command = Enum::RENAMENX;
778
        $args = [$key, $newKey];
779
780
        return $this->dispatch(Builder::build($command, $args));
781
    }
782
783
    public function restore($key, $ttl, $value)
784
    {
785
        // TODO: Implement restore() method.
786
        $command = Enum::RESTORE;
787
        $args = [$key, $ttl, $value];
788
789
        return $this->dispatch(Builder::build($command, $args));
790
    }
791
792 View Code Duplication
    public function ping($message = 'PING')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
793
    {
794
        $command = Enum::PING;
795
        $args = [$message];
796
797
        return $this->dispatch(Builder::build($command, $args));
798
    }
799
800
    public function quit()
801
    {
802
        $command = Enum::QUIT;
803
804
        return $this->dispatch(Builder::build($command));
805
    }
806
807
    public function setRange($key, $offset, $value)
808
    {
809
        $command = Enum::SETRANGE;
810
        $args = [$key, $offset, $value];
811
812
        return $this->dispatch(Builder::build($command, $args));
813
    }
814
815 View Code Duplication
    public function pTtl($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
816
    {
817
        $command = Enum::PTTL;
818
        $args = [$key];
819
820
        return $this->dispatch(Builder::build($command, $args));
821
    }
822
823
    public function pSetEx($key, $milliseconds, $value)
824
    {
825
        $command = Enum::PSETEX;
826
        $args = [$key, $milliseconds, $value];
827
828
        return $this->dispatch(Builder::build($command, $args));
829
    }
830
831
    public function hDel($key, ...$fields)
832
    {
833
        $command = Enum::HDEL;
834
        $args = [$key];
835
        $args = array_merge($args, $fields);
836
837
        return $this->dispatch(Builder::build($command, $args));
838
    }
839
840
    public function hGet($key, $field)
841
    {
842
        $command = Enum::HGET;
843
        $args = [$key, $field];
844
845
        return $this->dispatch(Builder::build($command, $args));
846
    }
847
848
    public function hGetAll($key)
849
    {
850
        $command = Enum::HGETALL;
851
        $args = [$key];
852
853
        return $this->dispatch(Builder::build($command, $args))->then(function ($value) {
854
            if (!empty($value)) {
855
                $tmp = [];
856
                $size = count($value);
857
                for ($i=0; $i<$size; $i+=2) {
858
                    $field = $value[$i];
859
                    $val = $value[$i+1];
860
                    $tmp[$field] = $val;
861
                }
862
                $value = $tmp;
863
            }
864
        
865
            return $value;
866
        });
867
    }
868
869
    public function hIncrBy($key, $field, $increment)
870
    {
871
        $command = Enum::HINCRBY;
872
        $args = [$key, $field, $increment];
873
874
        return $this->dispatch(Builder::build($command, $args));
875
    }
876
877
    public function hIncrByFloat($key, $field, $increment)
878
    {
879
        $command = Enum::HINCRBYFLOAT;
880
        $args = [$key, $field, $increment];
881
882
        return $this->dispatch(Builder::build($command, $args));
883
    }
884
885 View Code Duplication
    public function hKeys($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
886
    {
887
        $command = Enum::HKEYS;
888
        $args = [$key];
889
890
        return $this->dispatch(Builder::build($command, $args));
891
    }
892
893 View Code Duplication
    public function hLen($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
894
    {
895
        $command = Enum::HLEN;
896
        $args = [$key];
897
898
        return $this->dispatch(Builder::build($command, $args));
899
    }
900
901
    public function hMGet($key, ...$fields)
902
    {
903
        $command = Enum::HMGET;
904
        $args = [$key];
905
        $args = array_merge($args, $fields);
906
907
        return $this->dispatch(Builder::build($command, $args));
908
    }
909
910
    public function hMSet($key, array $fvMap)
911
    {
912
        $command = Enum::HMSET;
913
        $args = [$key];
914
        if (!empty($fvMap)) {
915
            foreach ($fvMap as $field => $value) {
916
                $tmp[] = $field;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$tmp was never initialized. Although not strictly required by PHP, it is generally a good practice to add $tmp = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
917
                $tmp[] = $value;
918
            }
919
            $fvMap = $tmp;        
0 ignored issues
show
Bug introduced by
The variable $tmp does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
920
        }
921
        $args = array_merge($args, $fvMap);
922
923
        return $this->dispatch(Builder::build($command, $args));
924
    }
925
926
    public function hSet($key, $field, $value)
927
    {
928
        $command = Enum::HSET;
929
        $args = [$key, $field, $value];
930
931
        return $this->dispatch(Builder::build($command, $args));
932
    }
933
934
    public function hSetNx($key, $filed, $value)
935
    {
936
        $command = Enum::HSETNX;
937
        $args = [$key, $filed, $value];
938
939
        return $this->dispatch(Builder::build($command, $args));
940
    }
941
942
    public function hStrLen($key, $field)
943
    {
944
        $command = Enum::HSTRLEN;
945
        $args = [$key, $field];
946
947
        return $this->dispatch(Builder::build($command, $args));
948
    }
949
950 View Code Duplication
    public function hVals($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
951
    {
952
        $command = Enum::HVALS;
953
        $args = [$key];
954
955
        return $this->dispatch(Builder::build($command, $args));
956
    }
957
958
    public function geoAdd($key, array $coordinates)
959
    {
960
        // TODO: Implement geoAdd() method.
961
        $command = Enum::GEOADD;
962
        $args = [$key];
963
        $args = array_merge($args, $coordinates);
964
965
        return $this->dispatch(Builder::build($command, $args));
966
    }
967
968
    public function geoHash($key, ...$members)
969
    {
970
        // TODO: Implement geoHash() method.
971
        $command = Enum::GEOHASH;
0 ignored issues
show
Unused Code introduced by
$command is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
972
    }
973
974
    public function geoPos($key, ...$members)
975
    {
976
        // TODO: Implement geoPos() method.
977
        $command = Enum::GEOPOS;
978
        $args = [$key];
979
        $args = array_merge($args, $members);
980
981
        return $this->dispatch(Builder::build($command, $args));
982
    }
983
984
    public function geoDist($key, $memberA, $memberB, $unit)
985
    {
986
        // TODO: Implement geoDist() method.
987
        $command = Enum::GEODIST;
988
        $args = [$key, $memberA, $memberB ,$unit];
989
990
        return $this->dispatch(Builder::build($command, $args));
991
    }
992
993 View Code Duplication
    public function geoRadius($key, $longitude, $latitude, $unit, $command, $count, $sort)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
994
    {
995
        // TODO: Implement geoRadius() method.
996
        $command = Enum::GEORADIUS;
997
        $args = [$key, $longitude, $latitude, $unit, $command, $count, $sort];
998
999
        return $this->dispatch(Builder::build($command, $args));
1000
    }
1001
1002 View Code Duplication
    public function geoRadiusByMember($key, $member, $unit, $command, $count, $sort, $store, $storeDist)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1003
    {
1004
        // TODO: Implement geoRadiusByMember() method.
1005
        $command = Enum::GEORADIUSBYMEMBER;
1006
        $args = [$key, $member, $unit, $command, $count, $sort, $store, $storeDist];
1007
1008
        return $this->dispatch(Builder::build($command, $args));
1009
    }
1010
1011
    public function pSubscribe(...$patterns)
1012
    {
1013
        // TODO: Implement pSubscribe() method.
1014
        $command = Enum::PSUBSCRIBE;
1015
        $args = $patterns;
1016
1017
        return $this->dispatch(Builder::build($command, $args));
1018
    }
1019
1020
    public function pubSub($command, array $args = [])
1021
    {
1022
        // TODO: Implement pubSub() method.
1023
        $command = Enum::PUBSUB;
1024
1025
        return $this->dispatch(Builder::build($command, $args));
1026
    }
1027
1028 View Code Duplication
    public function publish($channel, $message)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1029
    {
1030
        // TODO: Implement publish() method.
1031
        $command = Enum::PUBLISH;
1032
        $args = [$channel, $message];
1033
1034
        return $this->dispatch(Builder::build($command, $args));
1035
    }
1036
1037
    public function pUnsubscribe(...$patterns)
1038
    {
1039
        // TODO: Implement pUnsubscribe() method.
1040
        $command = Enum::PUNSUBSCRIBE;
1041
        $args = $patterns;
1042
1043
        return $this->dispatch(Builder::build($command, $args));
1044
    }
1045
1046
    public function unSubscribe(...$channels)
1047
    {
1048
        // TODO: Implement unSubscribe() method.
1049
        $command = Enum::UNSUBSCRIBE;
1050
        $args = $channels;
1051
1052
        return $this->dispatch(Builder::build($command, $args));
1053
    }
1054
1055
    public function lIndex($key, $index)
1056
    {
1057
        // TODO: Implement lIndex() method.
1058
        $command = Enum::LINDEX;
1059
        $args = [$key, $index];
1060
1061
        return $this->dispatch(Builder::build($command, $args));
1062
    }
1063
1064
    public function lInsert($key, $action, $pivot, $value)
1065
    {
1066
        // TODO: Implement lInsert() method.
1067
        $command = Enum::LINSERT;
1068
        $args = [$key, $action, $pivot, $value];
1069
1070
        return $this->dispatch(Builder::build($command, $args));
1071
    }
1072
1073 View Code Duplication
    public function lLen($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1074
    {
1075
        // TODO: Implement lLen() method.
1076
        $command = Enum::LLEN;
1077
        $args = [$key];
1078
1079
        return $this->dispatch(Builder::build($command, $args));
1080
    }
1081
1082 View Code Duplication
    public function lPop($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1083
    {
1084
        // TODO: Implement lPop() method.
1085
        $command = Enum::LPOP;
1086
        $args = [$key];
1087
1088
        return $this->dispatch(Builder::build($command, $args));
1089
    }
1090
1091
    public function lPush($key,...$values)
1092
    {
1093
        $command = Enum::LPUSH;
1094
        array_unshift($values, $key);
1095
1096
        return $this->dispatch(Builder::build($command, $values));
1097
    }
1098
1099
    public function lPushX($key, $value)
1100
    {
1101
        $command = Enum::LPUSHX;
1102
        $args = [$key, $value];
1103
1104
        return $this->dispatch(Builder::build($command, $args));
1105
    }
1106
1107
    public function lRange($key, $start = 0, $stop = -1)
1108
    {
1109
        $command = Enum::LRANGE;
1110
        $args = [$key, $start, $stop];
1111
1112
        return $this->dispatch(Builder::build($command, $args));
1113
    }
1114
1115
    public function lRem($key, $count, $value)
1116
    {
1117
        // TODO: Implement lRem() method.
1118
        $command = Enum::LREM;
1119
        $args = [$key, $count, $value];
1120
1121
        return $this->dispatch(Builder::build($command, $args));
1122
    }
1123
1124
    public function lSet($key, $index, $value)
1125
    {
1126
        // TODO: Implement lSet() method.
1127
        $command = Enum::LSET;
1128
        $args = [$key, $index, $value];
1129
1130
        return $this->dispatch(Builder::build($command, $args));
1131
    }
1132
1133
    public function lTrim($key, $start, $stop)
1134
    {
1135
        // TODO: Implement lTrim() method.
1136
        $command = Enum::LTRIM;
1137
        $args = [$key, $start, $stop];
1138
1139
        return $this->dispatch(Builder::build($command, $args));
1140
    }
1141
1142
    public function mGet($key, ...$values)
1143
    {
1144
        // TODO: Implement mGet() method.
1145
        $command = Enum::MGET;
1146
        $args = [$key];
1147
        $args = array_merge($args, $values);
1148
1149
        return $this->dispatch(Builder::build($command, $args));
1150
    }
1151
1152
    public function mSet(array $kvMap)
1153
    {
1154
        // TODO: Implement mSet() method.
1155
        $command = Enum::MSET;
1156
        $args = $kvMap;
1157
1158
        return $this->dispatch(Builder::build($command, $args));
1159
    }
1160
1161
    public function monitor()
1162
    {
1163
        // TODO: Implement monitor() method.
1164
        $command = Enum::MONITOR;
1165
1166
        return $this->dispatch(Builder::build($command));
1167
    }
1168
1169
    public function move($key, $db)
1170
    {
1171
        // TODO: Implement move() method.
1172
        $command = Enum::MOVE;
1173
        $args = [$key, $db];
1174
1175
        return $this->dispatch(Builder::build($command, $args));
1176
    }
1177
1178
    public function mSetNx($kvMap)
1179
    {
1180
        // TODO: Implement mSetNx() method.
1181
        $command = Enum::MSETNX;
1182
        $args = $kvMap;
1183
1184
        return $this->dispatch(Builder::build($command, $args));
1185
    }
1186
1187 View Code Duplication
    public function rPop($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1188
    {
1189
        $command = Enum::RPOP;
1190
        $args = [$key];
1191
1192
        return $this->dispatch(Builder::build($command, $args));
1193
    }
1194
1195 View Code Duplication
    public function rPopLPush($src, $dst)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1196
    {
1197
        // TODO: Implement rPopLPush() method.
1198
        $command = Enum::RPOPLPUSH;
1199
        $args = [$src, $dst];
1200
1201
        return $this->dispatch(Builder::build($command, $args));
1202
    }
1203
1204
    public function rPush($key, ...$values)
1205
    {
1206
        $command = Enum::RPUSH;
1207
        $args = [$key];
1208
        $args = array_merge($args, $values);
1209
1210
        return $this->dispatch(Builder::build($command, $args));
1211
    }
1212
1213
    public function rPushX($key, $value)
1214
    {
1215
        $command = Enum::RPUSHX;
1216
        $args = [$key, $value];
1217
1218
        return $this->dispatch(Builder::build($command, $args));
1219
    }
1220
1221
    public function pFAdd($key, ...$elements)
1222
    {
1223
        // TODO: Implement pFAdd() method.
1224
        $command = Enum::PFADD;
1225
        $args = [$key];
1226
        $args = array_merge($args, $elements);
1227
1228
        return $this->dispatch(Builder::build($command, $args));
1229
    }
1230
1231
    public function pFCount(...$keys)
1232
    {
1233
        // TODO: Implement pFCount() method.
1234
        $command = Enum::PFCOUNT;
1235
        $args = $keys;
1236
1237
        return $this->dispatch(Builder::build($command, $args));
1238
    }
1239
1240
    public function pFMerge(array $dsKeyMap)
1241
    {
1242
        // TODO: Implement pFMerge() method.
1243
        $command = Enum::PFMERGE;
1244
        $args = $dsKeyMap;
1245
1246
        return $this->dispatch(Builder::build($command, $args));
1247
    }
1248
1249
    public function clusterAddSlots(...$slots)
1250
    {
1251
        // TODO: Implement clusterAddSlots() method.
1252
        $command = Enum::CLUSTER_ADDSLOTS;
1253
        $args = $slots;
1254
1255
        return $this->dispatch(Builder::build($command, $args));
1256
    }
1257
1258
    public function clusterCountFailureReports($nodeId)
1259
    {
1260
        // TODO: Implement clusterCountFailureReports() method.
1261
        $command = Enum::CLUSTER_COUNT_FAILURE_REPORTS;
1262
        $args = [$nodeId];
1263
1264
        return $this->dispatch(Builder::build($command, $args));
1265
    }
1266
1267
    public function clusterCountKeysInSlot($slot)
1268
    {
1269
        // TODO: Implement clusterCountKeysInSlot() method.
1270
        $command = Enum::CLUSTER_COUNTKEYSINSLOT;
1271
        $args = $slot;
1272
1273
        return $this->dispatch(Builder::build($command, $args));
1274
    }
1275
1276
    public function clusterDelSlots(...$slots)
1277
    {
1278
        // TODO: Implement clusterDelSlots() method.
1279
        $command = Enum::CLUSTER_DELSLOTS;
1280
        $args = $slots;
1281
1282
        return $this->dispatch(Builder::build($command, $args));
1283
    }
1284
1285
    public function clusterFailOver($operation)
1286
    {
1287
        // TODO: Implement clusterFailOver() method.
1288
    }
1289
1290
    public function clusterForget($nodeId)
1291
    {
1292
        // TODO: Implement clusterForget() method.
1293
    }
1294
1295
    public function clusterGetKeyInSlot($slot, $count)
1296
    {
1297
        // TODO: Implement clusterGetKeyInSlot() method.
1298
    }
1299
1300
    public function clusterInfo()
1301
    {
1302
        // TODO: Implement clusterInfo() method.
1303
        $command = Enum::CLUSTER_INFO;
1304
1305
        return $this->dispatch(Builder::build($command));
1306
    }
1307
1308 View Code Duplication
    public function clusterKeySlot($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1309
    {
1310
        // TODO: Implement clusterKeySlot() method.
1311
        $command = Enum::CLUSTER_KEYSLOT;
1312
        $args = [$key];
1313
1314
        return $this->dispatch(Builder::build($command, $args));
1315
    }
1316
1317
    public function clusterMeet($ip, $port)
1318
    {
1319
        // TODO: Implement clusterMeet() method.
1320
        $command = Enum::CLUSTER_MEET;
1321
        $args = [$ip, $port];
1322
1323
        return $this->dispatch(Builder::build($command, $args));
1324
    }
1325
1326
    public function clusterNodes()
1327
    {
1328
        // TODO: Implement clusterNodes() method.
1329
    }
1330
1331
    public function clusterReplicate($nodeId)
1332
    {
1333
        // TODO: Implement clusterReplicate() method.
1334
    }
1335
1336
    public function clusterReset($mode)
1337
    {
1338
        // TODO: Implement clusterReset() method.
1339
    }
1340
1341
    public function clusterSaveConfig()
1342
    {
1343
        // TODO: Implement clusterSaveConfig() method.
1344
    }
1345
1346
    /**
1347
     * @inheritDoc
1348
     */
1349
    public function clusterSetConfigEpoch($configEpoch)
1350
    {
1351
        // TODO: Implement clusterSetConfigEpoch() method.
1352
    }
1353
1354
    /**
1355
     * @inheritDoc
1356
     */
1357
    public function clusterSetSlot($command, $nodeId)
1358
    {
1359
        // TODO: Implement clusterSetSlot() method.
1360
        $command = Enum::CLUSTER_SETSLOT;
1361
        $args = [$command, $nodeId];
1362
1363
        return $this->dispatch(Builder::build($command, $args));
1364
    }
1365
1366
    /**
1367
     * @inheritDoc
1368
     */
1369
    public function clusterSlaves($nodeId)
1370
    {
1371
        // TODO: Implement clusterSlaves() method.
1372
        $command = Enum::CLUSTER_SLAVES;
1373
        $args = [$nodeId];
1374
1375
        return $this->dispatch(Builder::build($command, $args));
1376
    }
1377
1378
    /**
1379
     * @inheritDoc
1380
     */
1381
    public function clusterSlots()
1382
    {
1383
        // TODO: Implement clusterSlots() method.
1384
        $command = Enum::CLUSTER_SLOTS;
1385
1386
        return $this->dispatch(Builder::build($command));
1387
    }
1388
1389
    public function flushAll()
1390
    {
1391
        $command = Enum::FLUSHALL;
1392
1393
        return $this->dispatch(Builder::build($command));
1394
    }
1395
1396 1
    public function flushDb()
1397
    {
1398
        // TODO: Implement flushDb() method.
1399 1
        $command = Enum::FLUSHDB;
1400
1401 1
        return $this->dispatch(Builder::build($command));
1402
    }
1403
1404
    public function info($section = [])
1405
    {
1406
        $command = Enum::INFO;
1407
1408
        return $this->dispatch(Builder::build($command, $section))->then(function ($value) {
1409
            if ($value) {
1410
                $ret = explode(PHP_EOL, $value);
1411
                $handled = [];
1412
                $lastKey = '';
1413
                foreach ($ret as $_ => $v) {
1414
                    if (($pos = strpos($v, '#')) !== false) {
1415
                        $lastKey = strtolower(substr($v,$pos+2));
1416
                        $handled[$lastKey] = [];
1417
                        continue;
1418
                    }
1419
                    $statMap = explode(':', $v);
1420
                    if ($statMap[0]) {
1421
                        list($name, $stat) = explode(':', $v);
1422
                        $handled[$lastKey][$name] = $stat;
1423
                    }
1424
                }
1425
1426
                return $handled;
1427
            }
1428
1429
            return $value;
1430
        });
1431
    }
1432
1433
    public function zAdd($key, array $options = [])
1434
    {
1435
        // TODO: Implement zAdd() method.
1436
        $command = Enum::ZADD;
1437
        $args = [$key];
1438
        $args = array_merge($args, $options);
1439
1440
        return $this->dispatch(Builder::build($command, $args));
1441
    }
1442
1443 View Code Duplication
    public function zCard($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1444
    {
1445
        // TODO: Implement zCard() method.
1446
        $command = Enum::ZCARD;
1447
        $args = [$key];
1448
1449
        return $this->dispatch(Builder::build($command, $args));
1450
    }
1451
1452 View Code Duplication
    public function zCount($key, $min, $max)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1453
    {
1454
        // TODO: Implement zCount() method.
1455
        $command = Enum::ZCOUNT;
1456
        $args = [$key, $min, $max];
1457
1458
        return $this->dispatch(Builder::build($command, $args));
1459
    }
1460
1461
    public function zIncrBy($key, $increment, $member)
1462
    {
1463
        // TODO: Implement zIncrBy() method.
1464
        $command = Enum::ZINCRBY;
1465
        $args = [$key, $increment, $member];
1466
1467
        return $this->dispatch(Builder::build($command, $args));
1468
    }
1469
1470
    public function zInterStore($dst, $numKeys)
1471
    {
1472
        // TODO: Implement zInterStore() method.
1473
        $command = Enum::ZINTERSTORE;
1474
        $args = [$dst, $numKeys];
1475
1476
        return $this->dispatch(Builder::build($command, $args));
1477
    }
1478
1479 View Code Duplication
    public function zLexCount($key, $min, $max)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1480
    {
1481
        // TODO: Implement zLexCount() method.
1482
        $command = Enum::ZLEXCOUNT;
1483
        $args = [$key, $min, $max];
1484
1485
        return $this->dispatch(Builder::build($command, $args));
1486
    }
1487
1488
    public function zRange($key, $star, $stop, array $options = [])
1489
    {
1490
        // TODO: Implement zRange() method.
1491
        $command = Enum::ZRANGE;
1492
        $args = [$key, $star,$stop];
1493
        $args = array_merge($args, $options);
1494
1495
        return $this->dispatch(Builder::build($command, $args));
1496
    }
1497
1498
    public function zRangeByLex($key, $min, $max, array $options = [])
1499
    {
1500
        // TODO: Implement zRangeByLex() method.
1501
        $command = Enum::ZRANGEBYLEX;
1502
        $args = [$key, $min, $max];
1503
        $args = array_merge($args,$options);
1504
1505
        return $this->dispatch(Builder::build($command, $args));
1506
    }
1507
1508
    public function zRevRangeByLex($key, $max, $min, array $options = [])
1509
    {
1510
        // TODO: Implement zRevRangeByLex() method.
1511
        $command = Enum::ZREVRANGEBYLEX;
1512
        $args = [$key, $max,$min];
1513
        $args = array_merge($args,$options);
1514
1515
        return $this->dispatch(Builder::build($command, $args));
1516
    }
1517
1518
    public function zRangeByScore($key, $min, $max, array $options = [])
1519
    {
1520
        // TODO: Implement zRangeByScore() method.
1521
        $command = Enum::ZRANGEBYSCORE;
1522
        $args = [$key, $min,$max];
1523
        $args = array_merge($args, $options);
1524
1525
        return $this->dispatch(Builder::build($command, $args));
1526
    }
1527
1528
    public function zRank($key, $member)
1529
    {
1530
        // TODO: Implement zRank() method.
1531
        $command = Enum::ZRANK;
1532
        $args = [$key,$member];
1533
1534
        return $this->dispatch(Builder::build($command, $args));
1535
    }
1536
1537
    public function zRem($key, ...$members)
1538
    {
1539
        // TODO: Implement zRem() method.
1540
        $command = Enum::ZREM;
1541
        $args = [$key];
1542
        $args = array_merge($args, $members);
1543
1544
        return $this->dispatch(Builder::build($command, $args));
1545
    }
1546
1547 View Code Duplication
    public function zRemRangeByLex($key, $min, $max)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1548
    {
1549
        // TODO: Implement zRemRangeByLex() method.
1550
        $command = Enum::ZREMRANGEBYLEX;
1551
        $args = [$key, $min, $max];
1552
1553
        return $this->dispatch(Builder::build($command, $args));
1554
    }
1555
1556
    public function zRemRangeByRank($key, $start, $stop)
1557
    {
1558
        // TODO: Implement zRemRangeByRank() method.
1559
        $command = Enum::ZREMRANGEBYRANK;
1560
        $args = [$key, $start,$stop];
1561
1562
        return $this->dispatch(Builder::build($command, $args));
1563
    }
1564
1565 View Code Duplication
    public function zRemRangeByScore($key, $min, $max)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1566
    {
1567
        // TODO: Implement zRemRangeByScore() method.
1568
        $command = Enum::ZREMRANGEBYSCORE;
1569
        $args = [$key, $min, $max];
1570
1571
        return $this->dispatch(Builder::build($command, $args));
1572
    }
1573
1574
    public function zRevRange($key, $start, $stop, array $options = [])
1575
    {
1576
        // TODO: Implement zRevRange() method.
1577
        $command = Enum::ZREVRANGE;
1578
        $args = [$key, $start, $stop];
1579
        $args = array_merge($args, $options);
1580
1581
        return $this->dispatch(Builder::build($command, $args));
1582
    }
1583
1584
    public function zRevRangeByScore($key, $max, $min, array $options = [])
1585
    {
1586
        // TODO: Implement zRevRangeByScore() method.
1587
        $command = Enum::ZREVRANGEBYSCORE;
1588
        $args = [$key,$max,$min];
1589
        $args = array_merge($args, $options);
1590
1591
        return $this->dispatch(Builder::build($command, $args));
1592
    }
1593
1594
    public function zRevRank($key, $member)
1595
    {
1596
        // TODO: Implement zRevRank() method.
1597
        $command = Enum::ZREVRANK;
1598
        $args = [$key,$member];
1599
1600
        return $this->dispatch(Builder::build($command, $args));
1601
    }
1602
1603
    public function zScore($key, $member)
1604
    {
1605
        // TODO: Implement zScore() method.
1606
        $command = Enum::ZSCORE;
1607
        $args = [$key,$member];
1608
1609
        return $this->dispatch(Builder::build($command, $args));
1610
    }
1611
1612
    public function scan($cursor, array $options = [])
1613
    {
1614
        $command = Enum::SCAN;
1615
        $args = [$cursor];
1616
        $args = array_merge($args, $options);
1617
1618
        return $this->dispatch(Builder::build($command, $args));
1619
    }
1620
1621
    public function sScan($key, $cursor, array $options = [])
1622
    {
1623
        // TODO: Implement sScan() method.
1624
        $command = Enum::SSCAN;
1625
        $args = [$key, $cursor];
1626
        $args = array_merge($args, $options);
1627
1628
        return $this->dispatch(Builder::build($command, $args));
1629
    }
1630
1631
    public function hScan($key, $cursor, array $options = [])
1632
    {
1633
        // TODO: Implement hScan() method.
1634
        $command = Enum::HSCAN;
1635
        $args = [$key, $cursor];
1636
        $args = array_merge($args, $options);
1637
1638
        return $this->dispatch(Builder::build($command, $args));
1639
    }
1640
1641
    public function zScan($key, $cursor, array $options = [])
1642
    {
1643
        // TODO: Implement zScan() method.
1644
        $command = Enum::ZSCAN;
1645
        $args = [$key , $cursor];
1646
        $args = array_merge($args, $options);
1647
1648
        return $this->dispatch(Builder::build($command, $args));
1649
    }
1650
1651
    public function sInter(...$keys)
1652
    {
1653
        // TODO: Implement sInter() method.
1654
        $command = Enum::SINTER;
1655
        $args = $keys;
1656
1657
        return $this->dispatch(Builder::build($command, $args));
1658
    }
1659
1660
    public function sInterStore($dst, ...$keys)
1661
    {
1662
        // TODO: Implement sInterStore() method.
1663
        $command = Enum::SINTERSTORE;
1664
        $args = [$dst];
1665
        $args = array_merge($args, $keys);
1666
1667
        return $this->dispatch(Builder::build($command, $args));
1668
    }
1669
1670
    public function sIsMember($key, $member)
1671
    {
1672
        // TODO: Implement sIsMember() method.
1673
        $command = Enum::SISMEMBER;
1674
        $args = [$key ,$member];
1675
1676
        return $this->dispatch(Builder::build($command, $args));
1677
    }
1678
1679 View Code Duplication
    public function slaveOf($host, $port)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1680
    {
1681
        // TODO: Implement slaveOf() method.
1682
        $command = Enum::SLAVEOF;
1683
        $args = [$host, $port];
1684
1685
        return $this->dispatch(Builder::build($command, $args));
1686
    }
1687
1688
    public function sLowLog($command, array $args = [])
1689
    {
1690
        // TODO: Implement sLowLog() method.
1691
        $command = Enum::SLOWLOG;
1692
        $args = array_merge([$command],$args);
1693
1694
        return $this->dispatch(Builder::build($command, $args));
1695
    }
1696
1697 View Code Duplication
    public function sMembers($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1698
    {
1699
        // TODO: Implement sMembers() method.
1700
        $command = Enum::SMEMBERS;
1701
        $args = [$key];
1702
1703
        return $this->dispatch(Builder::build($command, $args));
1704
    }
1705
1706
    public function sMove($src, $dst, $members)
1707
    {
1708
        // TODO: Implement sMove() method.
1709
        $command = Enum::SMOVE;
1710
        $args = [$src, $dst];
1711
        $args = array_merge( $args, $members);
1712
1713
        return $this->dispatch(Builder::build($command, $args));
1714
    }
1715
1716
    public function sort($key, array $options = [])
1717
    {
1718
        // TODO: Implement sort() method.
1719
        $command = Enum::SORT;
1720
        $args = [$key];
1721
        $args = array_merge($args, $options);
1722
1723
        return $this->dispatch(Builder::build($command, $args));
1724
    }
1725
1726 View Code Duplication
    public function sPop($key, $count)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1727
    {
1728
        // TODO: Implement sPop() method.
1729
        $command = Enum::SPOP;
1730
        $args = [$key, $count];
1731
1732
        return $this->dispatch(Builder::build($command, $args));
1733
    }
1734
1735 View Code Duplication
    public function sRandMember($key, $count)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1736
    {
1737
        // TODO: Implement sRandMember() method.
1738
        $command = Enum::SRANDMEMBER;
1739
        $args = [$key, $count];
1740
1741
        return $this->dispatch(Builder::build($command, $args));
1742
    }
1743
1744
    public function sRem($key, ...$members)
1745
    {
1746
        // TODO: Implement sRem() method.
1747
        $command = Enum::SREM;
1748
        $args = [$key];
1749
        $args = array_merge($args, $members);
1750
1751
        return $this->dispatch(Builder::build($command, $args));
1752
    }
1753
1754 View Code Duplication
    public function strLen($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1755
    {
1756
        // TODO: Implement strLen() method.
1757
        $command = Enum::STRLEN;
1758
        $args = [$key];
1759
1760
        return $this->dispatch(Builder::build($command, $args));
1761
    }
1762
1763
    public function subscribe(...$channels)
1764
    {
1765
        // TODO: Implement subscribe() method.
1766
        $command = Enum::SUBSCRIBE;
1767
        $args = $channels;
1768
1769
        return $this->dispatch(Builder::build($command, $args));
1770
    }
1771
1772
    public function sUnion(...$keys)
1773
    {
1774
        // TODO: Implement sUnion() method.
1775
        $command = Enum::SUNION;
1776
        $args = $keys;
1777
1778
        return $this->dispatch(Builder::build($command, $args));
1779
    }
1780
1781
    public function sUnionStore($dst, ...$keys)
1782
    {
1783
        // TODO: Implement sUnionStore() method.
1784
        $command = Enum::SUNIONSTORE;
1785
        $args = [$dst];
1786
        $args = array_merge($args, $keys);
1787
1788
        return $this->dispatch(Builder::build($command, $args));
1789
    }
1790
1791
    public function sWapBb($opt, $dst, ...$keys)
1792
    {
1793
        // TODO: Implement sWapBb() method.
1794
        $command = Enum::SWAPDB;
1795
        $args = [$opt, $dst];
1796
        $args = array_merge($args, $keys);
1797
1798
        return $this->dispatch(Builder::build($command, $args));
1799
    }
1800
1801
    public function sAdd($key, ...$members)
1802
    {
1803
        // TODO: Implement sAdd() method.
1804
        $command = Enum::SADD;
1805
        $args = [$key];
1806
        $args = array_merge($args, $members);
1807
1808
        return $this->dispatch(Builder::build($command, $args));
1809
    }
1810
1811
    public function save()
1812
    {
1813
        // TODO: Implement save() method.
1814
        $command = Enum::SAVE;
1815
1816
        return $this->dispatch(Builder::build($command));
1817
    }
1818
1819 View Code Duplication
    public function sCard($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1820
    {
1821
        // TODO: Implement sCard() method.
1822
        $command = Enum::SCARD;
1823
        $args = [$key];
1824
1825
        return $this->dispatch(Builder::build($command, $args));
1826
    }
1827
1828
    public function sDiff(...$keys)
1829
    {
1830
        // TODO: Implement sDiff() method.
1831
        $command = Enum::SDIFF;
1832
        $args = $keys;
1833
1834
        return $this->dispatch(Builder::build($command, $args));
1835
    }
1836
1837
    public function sDiffStore($dst, ...$keys)
1838
    {
1839
        // TODO: Implement sDiffStore() method.
1840
        $command = Enum::SDIFFSTORE;
1841
        $args = [$dst];
1842
        $args = array_merge($args, $keys);
1843
1844
        return $this->dispatch(Builder::build($command, $args));
1845
    }
1846
1847
    /**
1848
     * @inheritDoc
1849
     */
1850
    public function hExists($key, $field)
1851
    {
1852
        // TODO: Implement hExists() method.
1853
        $command = Enum::HEXISTS;
1854
        $args = [$key, $field];
1855
1856
        return $this->dispatch(Builder::build($command, $args));
1857
    }
1858
1859
    /**
1860
     * @inheritDoc
1861
     */
1862
    public function readWrite()
1863
    {
1864
        // TODO: Implement readWrite() method.
1865
        $command = Enum::READWRITE;
1866
1867
        return $this->dispatch(Builder::build($command));
1868
    }
1869
1870
    /**
1871
     * @inheritDoc
1872
     */
1873
    public function zUnionScore($dst, $numKeys)
1874
    {
1875
        // TODO: Implement zUnionScore() method.
1876
        $command = Enum::ZUNIIONSCORE;
1877
        $args = [$dst, $numKeys];
1878
1879
        return $this->dispatch(Builder::build($command, $args));
1880
    }
1881
};