Completed
Push — master ( 01354b...bfe60b )
by Kamil
12s
created

ApiSetTrait   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 196
Duplicated Lines 16.33 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 86.57%

Importance

Changes 0
Metric Value
dl 32
loc 196
c 0
b 0
f 0
wmc 15
lcom 1
cbo 1
ccs 58
cts 67
cp 0.8657
rs 10

16 Methods

Rating   Name   Duplication   Size   Complexity  
dispatch() 0 1 ?
A sScan() 0 8 1
A sInter() 0 7 1
A sInterStore() 0 8 1
A sIsMember() 0 7 1
A sMembers() 7 7 1
A sMove() 0 8 1
A sPop() 7 7 1
A sRandMember() 7 7 1
A sRem() 0 8 1
A sUnion() 0 7 1
A sUnionStore() 0 8 1
A sAdd() 0 8 1
A sCard() 7 7 1
A sDiff() 0 7 1
A sDiffStore() 0 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 ApiSetTrait
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 sScan($key, $cursor, array $options = [])
22
    {
23
        $command = Enum::SSCAN;
24
        $args = [$key, $cursor];
25
        $args = array_merge($args, $options);
26
27
        return $this->dispatch(Builder::build($command, $args));
28
    }
29
30
    /**
31
     * @override
32
     * @inheritDoc
33
     */
34
    public function sInter(...$keys)
35
    {
36
        $command = Enum::SINTER;
37
        $args = $keys;
38
39
        return $this->dispatch(Builder::build($command, $args));
40
    }
41
42
    /**
43
     * @override
44
     * @inheritDoc
45
     */
46 1
    public function sInterStore($dst, ...$keys)
47
    {
48 1
        $command = Enum::SINTERSTORE;
49 1
        $args = [$dst];
50 1
        $args = array_merge($args, $keys);
51
52 1
        return $this->dispatch(Builder::build($command, $args));
53
    }
54
55
    /**
56
     * @override
57
     * @inheritDoc
58
     */
59 1
    public function sIsMember($key, $member)
60
    {
61 1
        $command = Enum::SISMEMBER;
62 1
        $args = [$key ,$member];
63
64 1
        return $this->dispatch(Builder::build($command, $args));
65
    }
66
67
    /**
68
     * @override
69
     * @inheritDoc
70
     */
71 1 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...
72
    {
73 1
        $command = Enum::SMEMBERS;
74 1
        $args = [$key];
75
76 1
        return $this->dispatch(Builder::build($command, $args));
77
    }
78
79
    /**
80
     * @override
81
     * @inheritDoc
82
     */
83 1
    public function sMove($src, $dst, ...$members)
84
    {
85 1
        $command = Enum::SMOVE;
86 1
        $args = [$src, $dst];
87 1
        $args = array_merge($args, $members);
88
89 1
        return $this->dispatch(Builder::build($command, $args));
90
    }
91
92
    /**
93
     * @override
94
     * @inheritDoc
95
     */
96 1 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...
97
    {
98 1
        $command = Enum::SPOP;
99 1
        $args = [$key, $count];
100
101 1
        return $this->dispatch(Builder::build($command, $args));
102
    }
103
104
    /**
105
     * @override
106
     * @inheritDoc
107
     */
108 1 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...
109
    {
110 1
        $command = Enum::SRANDMEMBER;
111 1
        $args = [$key, $count];
112
113 1
        return $this->dispatch(Builder::build($command, $args));
114
    }
115
116
    /**
117
     * @override
118
     * @inheritDoc
119
     */
120 1
    public function sRem($key, ...$members)
121
    {
122 1
        $command = Enum::SREM;
123 1
        $args = [$key];
124 1
        $args = array_merge($args, $members);
125
126 1
        return $this->dispatch(Builder::build($command, $args));
127
    }
128
129
    /**
130
     * @override
131
     * @inheritDoc
132
     */
133 1
    public function sUnion(...$keys)
134
    {
135 1
        $command = Enum::SUNION;
136 1
        $args = $keys;
137
138 1
        return $this->dispatch(Builder::build($command, $args));
139
    }
140
141
    /**
142
     * @override
143
     * @inheritDoc
144
     */
145 1
    public function sUnionStore($dst, ...$keys)
146
    {
147 1
        $command = Enum::SUNIONSTORE;
148 1
        $args = [$dst];
149 1
        $args = array_merge($args, $keys);
150
151 1
        return $this->dispatch(Builder::build($command, $args));
152
    }
153
154
155
    /**
156
     * @override
157
     * @inheritDoc
158
     */
159 14
    public function sAdd($key, ...$members)
160
    {
161 14
        $command = Enum::SADD;
162 14
        $args = [$key];
163 14
        $args = array_merge($args, $members);
164
165 14
        return $this->dispatch(Builder::build($command, $args));
166
    }
167
168
    /**
169
     * @override
170
     * @inheritDoc
171
     */
172 1 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...
173
    {
174 1
        $command = Enum::SCARD;
175 1
        $args = [$key];
176
177 1
        return $this->dispatch(Builder::build($command, $args));
178
    }
179
180
    /**
181
     * @override
182
     * @inheritDoc
183
     */
184 1
    public function sDiff(...$keys)
185
    {
186 1
        $command = Enum::SDIFF;
187 1
        $args = $keys;
188
189 1
        return $this->dispatch(Builder::build($command, $args));
190
    }
191
192
    /**
193
     * @override
194
     * @inheritDoc
195
     */
196 1
    public function sDiffStore($dst, ...$keys)
197
    {
198 1
        $command = Enum::SDIFFSTORE;
199 1
        $args = [$dst];
200 1
        $args = array_merge($args, $keys);
201
202 1
        return $this->dispatch(Builder::build($command, $args));
203
    }
204
}
205