Completed
Push — master ( b586f8...cd674c )
by Kamil
12s
created

ApiTransactionTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 65
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
dispatch() 0 1 ?
A discard() 0 6 1
A exec() 0 6 1
A multi() 0 6 1
A unWatch() 0 6 1
A watch() 0 8 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 ApiTransactionTrait
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
    public function discard()
22
    {
23
        $command = Enum::DISCARD;
24
25
        return $this->dispatch(Builder::build($command));
26
    }
27
28
    /**
29
     * @override
30
     * @inheritDoc
31
     */
32
    public function exec()
33
    {
34
        $command = Enum::EXEC;
35
36
        return $this->dispatch(Builder::build($command));
37
    }
38
39
    /**
40
     * @override
41
     * @inheritDoc
42
     */
43
    public function multi()
44
    {
45
        $command = Enum::MULTI;
46
47
        return $this->dispatch(Builder::build($command));
48
    }
49
50
    /**
51
     * @override
52
     * @inheritDoc
53
     */
54
    public function unWatch()
55
    {
56
        $command = Enum::UNWATCH;
57
58
        return $this->dispatch(Builder::build($command));
59
    }
60
61
    /**
62
     * @override
63
     * @inheritDoc
64
     */
65
    public function watch($key, ...$keys)
66
    {
67
        $command = Enum::WATCH;
68
        $args = [$key];
69
        $args = array_merge($args, $keys);
70
71
        return $this->dispatch(Builder::build($command, $args));
72
    }
73
}
74