Completed
Push — master ( b586f8...cd674c )
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 0%

Importance

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