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

ApiHyperLogTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 15.56 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 7
loc 45
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
dispatch() 0 1 ?
A pFAdd() 0 8 1
A pFCount() 0 7 1
A pFMerge() 7 7 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 ApiHyperLogTrait
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 pFAdd($key, ...$elements)
22
    {
23
        $command = Enum::PFADD;
24
        $args = [$key];
25
        $args = array_merge($args, $elements);
26
27
        return $this->dispatch(Builder::build($command, $args));
28
    }
29
30
    /**
31
     * @override
32
     * @inheritDoc
33
     */
34
    public function pFCount(...$keys)
35
    {
36
        $command = Enum::PFCOUNT;
37
        $args = $keys;
38
39
        return $this->dispatch(Builder::build($command, $args));
40
    }
41
42
    /**
43
     * @override
44
     * @inheritDoc
45
     */
46 View Code Duplication
    public function pFMerge($dstKey, ...$srcKeys)
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...
47
    {
48
        $command = Enum::PFMERGE;
49
        $args = array_merge([$dstKey], $srcKeys);
50
51
        return $this->dispatch(Builder::build($command, $args));
52
    }
53
}
54