Completed
Push — master ( d90c1d...0cd5aa )
by Kamil
02:54
created

ApiKeyValTrait::strLen()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 7
loc 7
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Dazzle\Redis\Command\Compose;
4
5
use Dazzle\Redis\Command\Builder;
6
use Dazzle\Redis\Command\Enum;
7
use Dazzle\Redis\Driver\Request;
8
9
trait ApiKeyValTrait
10
{
11
    /**
12
     * @param Request $request
13
     * @return mixed
14
     */
15
    abstract function dispatch(Request $request);
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
16
17
    /**
18
     * @override
19
     * @inheritDoc
20
     */
21 1 View Code Duplication
    public function append($key, $value)
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...
22
    {
23 1
        $command = Enum::APPEND;
24 1
        $args = [$key, $value];
25
26 1
        return $this->dispatch(Builder::build($command, $args));
27
    }
28
29
    /**
30
     * @override
31
     * @inheritDoc
32
     */
33 1 View Code Duplication
    public function bitCount($key, $start = 0, $end = -1)
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...
34
    {
35 1
        $command = Enum::BITCOUNT;
36 1
        $args = [$key, $start, $end];
37
38 1
        return $this->dispatch(Builder::build($command, $args));
39
    }
40
41
    /**
42
     * @override
43
     * @inheritDoc
44
     */
45 1
    public function bitField($key, $subCommand, ...$param)
46
    {
47 1
        $command = Enum::BITFIELD;
48 1
        $subCommand = strtoupper($subCommand);
49
        //TODO: control flow improvement
50
        switch ($subCommand) {
51 1 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...
52 1
                @list ($type, $offset) = $param;
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
53 1
                $args = [$key, $subCommand, $type, $offset];
54 1
                break;
55
            }
56 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...
57
                @list ($type, $offset, $value) = $param;
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
58
                $args = [$key, $subCommand, $type, $offset, $value];
59
                break;
60
            }
61
            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...
62
                @list ($type, $offset, $increment) = $param;
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
63
                $args = [$key, $type, $offset, $increment];
64
                break;
65
            }
66
            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...
67
                @list ($behavior) = $param;
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
68
                $args = [$key, $subCommand, $behavior];
69
                break;
70
            }
71
            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...
72
                $args = [];
73
                break;
74
            }
75
        }
76
77 1
        return $this->dispatch(Builder::build($command, $args));
78
    }
79
80
    /**
81
     * @override
82
     * @inheritDoc
83
     */
84 1
    public function bitOp($operation, $dstKey, $srcKey, ...$keys)
85
    {
86 1
        $command = Enum::BITOP;
87 1
        $args = [$operation, $dstKey, $srcKey];
88 1
        $args = array_merge($args, $keys);
89
90 1
        return $this->dispatch(Builder::build($command, $args));
91
    }
92
93
    /**
94
     * @override
95
     * @inheritDoc
96
     */
97 1 View Code Duplication
    public function bitPos($key, $bit, $start = 0, $end = -1)
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...
98
    {
99 1
        $command = Enum::BITPOS;
100 1
        $args = [$key, $bit, $start, $end];
101
102 1
        return $this->dispatch(Builder::build($command, $args));
103
    }
104
105
    /**
106
     * @override
107
     * @inheritDoc
108
     */
109 1 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...
110
    {
111 1
        $command = Enum::DECR;
112 1
        $args = [$key];
113
114 1
        return $this->dispatch(Builder::build($command, $args));
115
    }
116
117
    /**
118
     * @override
119
     * @inheritDoc
120
     */
121 1
    public function decrBy($key, $decrement)
122
    {
123 1
        $command = Enum::DECRBY;
124 1
        $args = [$key, $decrement];
125
126 1
        return $this->dispatch(Builder::build($command, $args));
127
    }
128
129
    /**
130
     * @override
131
     * @inheritDoc
132
     */
133 5 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...
134
    {
135 5
        $command = Enum::GET;
136 5
        $args = [$key];
137
138 5
        return $this->dispatch(Builder::build($command, $args));
139
    }
140
141
    /**
142
     * @override
143
     * @inheritDoc
144
     */
145 2
    public function getBit($key, $offset)
146
    {
147 2
        $command = Enum::GETBIT;
148 2
        $args = [$key, $offset];
149
150 2
        return $this->dispatch(Builder::build($command, $args));
151
    }
152
153
    /**
154
     * @override
155
     * @inheritDoc
156
     */
157 1
    public function getRange($key, $start, $end)
158
    {
159 1
        $command = Enum::GETRANGE;
160 1
        $args = [$key, $start, $end];
161
162 1
        return $this->dispatch(Builder::build($command, $args));
163
    }
164
165
    /**
166
     * @override
167
     * @inheritDoc
168
     */
169 1
    public function getSet($key, $value)
170
    {
171 1
        $command = Enum::GETSET;
172 1
        $args = [$key, $value];
173
174 1
        return $this->dispatch(Builder::build($command, $args));
175
    }
176
177
    /**
178
     * @override
179
     * @inheritDoc
180
     */
181 1 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...
182
    {
183 1
        $command = Enum::INCR;
184 1
        $args = [$key];
185
186 1
        return $this->dispatch(Builder::build($command, $args));
187
    }
188
189
    /**
190
     * @override
191
     * @inheritDoc
192
     */
193 1
    public function incrBy($key, $increment)
194
    {
195 1
        $command = Enum::INCRBY;
196 1
        $args = [$key, $increment];
197
198 1
        return $this->dispatch(Builder::build($command, $args));
199
    }
200
201
    /**
202
     * @override
203
     * @inheritDoc
204
     */
205 1
    public function incrByFloat($key, $increment)
206
    {
207 1
        $command = Enum::INCRBYFLOAT;
208 1
        $args = [$key, $increment];
209
210 1
        return $this->dispatch(Builder::build($command, $args));
211
    }
212
213
    /**
214
     * @override
215
     * @inheritDoc
216
     */
217 29
    public function set($key, $value, array $options = [])
218
    {
219 29
        $command = Enum::SET;
220 29
        array_unshift($options, $key, $value);
221 29
        $args = $options;
222
223 29
        return $this->dispatch(Builder::build($command, $args));
224
    }
225
226
    /**
227
     * @override
228
     * @inheritDoc
229
     */
230 2
    public function setBit($key, $offset, $value)
231
    {
232 2
        $command = Enum::SETBIT;
233 2
        $args = [$key, $offset, $value];
234
235 2
        return $this->dispatch(Builder::build($command, $args));
236
    }
237
238
    /**
239
     * @override
240
     * @inheritDoc
241
     */
242 3
    public function setEx($key, $seconds, $value)
243
    {
244 3
        $command = Enum::SETEX;
245 3
        $args = [$key, $seconds, $value];
246
247 3
        return $this->dispatch(Builder::build($command, $args));
248
    }
249
250
    /**
251
     * @override
252
     * @inheritDoc
253
     */
254 1 View Code Duplication
    public function setNx($key, $value)
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...
255
    {
256 1
        $command = Enum::SETNX;
257 1
        $args = [$key, $value];
258
259 1
        return $this->dispatch(Builder::build($command, $args));
260
    }
261
262
    /**
263
     * @override
264
     * @inheritDoc
265
     */
266 1
    public function setRange($key, $offset, $value)
267
    {
268 1
        $command = Enum::SETRANGE;
269 1
        $args = [$key, $offset, $value];
270
271 1
        return $this->dispatch(Builder::build($command, $args));
272
    }
273
274
    /**
275
     * @override
276
     * @inheritDoc
277
     */
278 1
    public function pSetEx($key, $milliseconds, $value)
279
    {
280 1
        $command = Enum::PSETEX;
281 1
        $args = [$key, $milliseconds, $value];
282
283 1
        return $this->dispatch(Builder::build($command, $args));
284
    }
285
286
    /**
287
     * @override
288
     * @inheritDoc
289
     */
290 3
    public function mGet($key, ...$keys)
291
    {
292 3
        $command = Enum::MGET;
293 3
        $args = [$key];
294 3
        $args = array_merge($args, $keys);
295
296 3
        return $this->dispatch(Builder::build($command, $args));
297
    }
298
299
    /**
300
     * @override
301
     * @inheritDoc
302
     */
303 2 View Code Duplication
    public function mSet(array $kvMap)
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...
304
    {
305
        //TODO: change the param $kvMap to ...$kv,cauz map not allow duplicate key
306 2
        $command = Enum::MSET;
307 2
        $args = [];
308 2
        if (!empty($kvMap)) {
309 2
            foreach ($kvMap as $key => $val) {
310 2
                $args[] = $key;
311 2
                $args[] = $val;
312
            }
313
        }
314
315 2
        return $this->dispatch(Builder::build($command, $args));
316
    }
317
318
    /**
319
     * @override
320
     * @inheritDoc
321
     */
322 1 View Code Duplication
    public function mSetNx($kvMap)
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...
323
    {
324 1
        $command = Enum::MSETNX;
325 1
        $args = [];
326 1
        if (!empty($kvMap)) {
327 1
            foreach ($kvMap as $key => $val) {
328 1
                $args[] = $key;
329 1
                $args[] = $val;
330
            }
331
        }
332
333 1
        return $this->dispatch(Builder::build($command, $args));
334
    }
335
336
    /**
337
     * @override
338
     * @inheritDoc
339
     */
340 1 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...
341
    {
342 1
        $command = Enum::STRLEN;
343 1
        $args = [$key];
344
345 1
        return $this->dispatch(Builder::build($command, $args));
346
    }
347
348
    /**
349
     * @override
350
     * @inheritDoc
351
     */
352 2 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...
353
    {
354 2
        $command = Enum::DEL;
355 2
        $keys[] = $key;
356 2
        $args = $keys;
357
358 2
        return $this->dispatch(Builder::build($command, $args));
359
    }
360
361
    /**
362
     * @override
363
     * @inheritDoc
364
     */
365 2 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...
366
    {
367 2
        $command = Enum::DUMP;
368 2
        $args = [$key];
369
370 2
        return $this->dispatch(Builder::build($command, $args));
371
    }
372
373
    /**
374
     * @override
375
     * @inheritDoc
376
     */
377 1
    public function exists($key, ...$keys)
378
    {
379 1
        $command = Enum::EXISTS;
380 1
        $args = [$key];
381 1
        $args = array_merge($args, $keys);
382
383 1
        return $this->dispatch(Builder::build($command, $args));
384
    }
385
386
    /**
387
     * @override
388
     * @inheritDoc
389
     */
390
    public function expire($key, $seconds)
391
    {
392
        $command = Enum::EXPIRE;
393
        $args = [$key, $seconds];
394
395
        return $this->dispatch(Builder::build($command, $args));
396
    }
397
398
    /**
399
     * @override
400
     * @inheritDoc
401
     */
402 1
    public function expireAt($key, $timestamp)
403
    {
404 1
        $command = Enum::EXPIREAT;
405 1
        $args = [$key, $timestamp];
406
407 1
        return $this->dispatch(Builder::build($command, $args));
408
    }
409
410
    /**
411
     * @override
412
     * @inheritDoc
413
     */
414 1 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...
415
    {
416 1
        $command = Enum::PERSIST;
417 1
        $args = [$key];
418
419 1
        return $this->dispatch(Builder::build($command, $args));
420
    }
421
422
    /**
423
     * @override
424
     * @inheritDoc
425
     */
426 1
    public function pExpire($key, $milliseconds)
427
    {
428 1
        $command = Enum::PEXPIRE;
429 1
        $args = [$key, $milliseconds];
430
431 1
        return $this->dispatch(Builder::build($command, $args));
432
    }
433
434
    /**
435
     * @override
436
     * @inheritDoc
437
     */
438 1 View Code Duplication
    public function pExpireAt($key, $milTimestamp)
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...
439
    {
440 1
        $command = Enum::PEXPIREAT;
441 1
        $args = [$key, $milTimestamp];
442
443 1
        return $this->dispatch(Builder::build($command, $args));
444
    }
445
446
    /**
447
     * @override
448
     * @inheritDoc
449
     */
450 1
    public function touch($key, ...$keys)
451
    {
452 1
        $command = Enum::TOUCH;
453 1
        $args = [$key];
454 1
        $args = array_merge($args, $keys);
455
456 1
        return $this->dispatch(Builder::build($command, $args));
457
    }
458
459
    /**
460
     * @override
461
     * @inheritDoc
462
     */
463 2 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...
464
    {
465 2
        $command = Enum::TTL;
466 2
        $args = [$key];
467
468 2
        return $this->dispatch(Builder::build($command, $args));
469
    }
470
471
    /**
472
     * @override
473
     * @inheritDoc
474
     */
475 1 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...
476
    {
477 1
        $command = Enum::TYPE;
478 1
        $args = [$key];
479
480 1
        return $this->dispatch(Builder::build($command, $args));
481
    }
482
483
    /**
484
     * @override
485
     * @inheritDoc
486
     */
487
    public function unLink($key, ...$keys)
488
    {
489
        $command = Enum::UNLINK;
490
        $args = [$key];
491
        $args = array_merge($args, $keys);
492
493
        return $this->dispatch(Builder::build($command, $args));
494
    }
495
496
    /**
497
     * @override
498
     * @inheritDoc
499
     */
500
    public function wait($numSlaves, $timeout)
501
    {
502
        $command = Enum::WAIT;
503
        $args = [$numSlaves, $timeout];
504
505
        return $this->dispatch(Builder::build($command, $args));
506
    }
507
508
    /**
509
     * @override
510
     * @inheritDoc
511
     */
512 1
    public function randomKey()
513
    {
514 1
        $command = Enum::RANDOMKEY;
515
516 1
        return $this->dispatch(Builder::build($command));
517
    }
518
519
    /**
520
     * @override
521
     * @inheritDoc
522
     */
523 1
    public function rename($key, $newKey)
524
    {
525 1
        $command = Enum::RENAME;
526 1
        $args = [$key, $newKey];
527
528 1
        return $this->dispatch(Builder::build($command, $args));
529
    }
530
531
    /**
532
     * @override
533
     * @inheritDoc
534
     */
535 1
    public function renameNx($key, $newKey)
536
    {
537 1
        $command = Enum::RENAMENX;
538 1
        $args = [$key, $newKey];
539
540 1
        return $this->dispatch(Builder::build($command, $args));
541
    }
542
543
    /**
544
     * @override
545
     * @inheritDoc
546
     */
547 1
    public function restore($key, $ttl, $value)
548
    {
549 1
        $command = Enum::RESTORE;
550 1
        $args = [$key, $ttl, $value];
551
552 1
        return $this->dispatch(Builder::build($command, $args));
553
    }
554
555
    /**
556
     * @override
557
     * @inheritDoc
558
     */
559 3 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...
560
    {
561 3
        $command = Enum::PTTL;
562 3
        $args = [$key];
563
564 3
        return $this->dispatch(Builder::build($command, $args));
565
    }
566
567
    /**
568
     * @override
569
     * @inheritDoc
570
     */
571
    public function move($key, $db)
572
    {
573
        $command = Enum::MOVE;
574
        $args = [$key, $db];
575
576
        return $this->dispatch(Builder::build($command, $args));
577
    }
578
579
    /**
580
     * @override
581
     * @inheritDoc
582
     */
583
    public function scan($cursor, array $options = [])
584
    {
585
        $command = Enum::SCAN;
586
        $args = [$cursor];
587
        $args = array_merge($args, $options);
588
589
        return $this->dispatch(Builder::build($command, $args));
590
    }
591
592
    /**
593
     * @override
594
     * @inheritDoc
595
     */
596
    public function sort($key, array $options = [])
597
    {
598
        $command = Enum::SORT;
599
        $args = [$key];
600
        $args = array_merge($args, $options);
601
602
        return $this->dispatch(Builder::build($command, $args));
603
    }
604
605
    /**
606
     * @override
607
     * @inheritDoc
608
     */
609 1
    public function keys($key = '*')
610
    {
611 1
        $command = Enum::KEYS;
612 1
        $args = [$key];
613
614 1
        return $this->dispatch(Builder::build($command, $args));
615
    }
616
}
617