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

ApiSetTrait   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 195
Duplicated Lines 20 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 86.36%

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 1
dl 39
loc 195
ccs 57
cts 66
cp 0.8636
rs 10
c 0
b 0
f 0

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() 7 7 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 View Code Duplication
    public function sMove($src, $dst, $member)
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...
84
    {
85 1
        $command = Enum::SMOVE;
86 1
        $args = [$src, $dst, $member];
87
88 1
        return $this->dispatch(Builder::build($command, $args));
89
    }
90
91
    /**
92
     * @override
93
     * @inheritDoc
94
     */
95 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...
96
    {
97 1
        $command = Enum::SPOP;
98 1
        $args = [$key, $count];
99
100 1
        return $this->dispatch(Builder::build($command, $args));
101
    }
102
103
    /**
104
     * @override
105
     * @inheritDoc
106
     */
107 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...
108
    {
109 1
        $command = Enum::SRANDMEMBER;
110 1
        $args = [$key, $count];
111
112 1
        return $this->dispatch(Builder::build($command, $args));
113
    }
114
115
    /**
116
     * @override
117
     * @inheritDoc
118
     */
119 1
    public function sRem($key, ...$members)
120
    {
121 1
        $command = Enum::SREM;
122 1
        $args = [$key];
123 1
        $args = array_merge($args, $members);
124
125 1
        return $this->dispatch(Builder::build($command, $args));
126
    }
127
128
    /**
129
     * @override
130
     * @inheritDoc
131
     */
132 1
    public function sUnion(...$keys)
133
    {
134 1
        $command = Enum::SUNION;
135 1
        $args = $keys;
136
137 1
        return $this->dispatch(Builder::build($command, $args));
138
    }
139
140
    /**
141
     * @override
142
     * @inheritDoc
143
     */
144 1
    public function sUnionStore($dst, ...$keys)
145
    {
146 1
        $command = Enum::SUNIONSTORE;
147 1
        $args = [$dst];
148 1
        $args = array_merge($args, $keys);
149
150 1
        return $this->dispatch(Builder::build($command, $args));
151
    }
152
153
154
    /**
155
     * @override
156
     * @inheritDoc
157
     */
158 14
    public function sAdd($key, ...$members)
159
    {
160 14
        $command = Enum::SADD;
161 14
        $args = [$key];
162 14
        $args = array_merge($args, $members);
163
164 14
        return $this->dispatch(Builder::build($command, $args));
165
    }
166
167
    /**
168
     * @override
169
     * @inheritDoc
170
     */
171 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...
172
    {
173 1
        $command = Enum::SCARD;
174 1
        $args = [$key];
175
176 1
        return $this->dispatch(Builder::build($command, $args));
177
    }
178
179
    /**
180
     * @override
181
     * @inheritDoc
182
     */
183 1
    public function sDiff(...$keys)
184
    {
185 1
        $command = Enum::SDIFF;
186 1
        $args = $keys;
187
188 1
        return $this->dispatch(Builder::build($command, $args));
189
    }
190
191
    /**
192
     * @override
193
     * @inheritDoc
194
     */
195 1
    public function sDiffStore($dst, ...$keys)
196
    {
197 1
        $command = Enum::SDIFFSTORE;
198 1
        $args = [$dst];
199 1
        $args = array_merge($args, $keys);
200
201 1
        return $this->dispatch(Builder::build($command, $args));
202
    }
203
}
204