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

ApiSetTrait::sAdd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
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 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