Completed
Push — master ( 9e125a...9a1e57 )
by Kamil
02:25
created

ApiGeospatialTrait::geoAdd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
ccs 0
cts 5
cp 0
rs 9.6666
nc 1
cc 1
eloc 5
nop 2
crap 2
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 ApiGeospatialTrait
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 geoAdd($key, array $coordinates)
22
    {
23
        // TODO: Implement geoAdd() method.
24
        $command = Enum::GEOADD;
25
        $args = [$key];
26
        $args = array_merge($args, $coordinates);
27
28
        return $this->dispatch(Builder::build($command, $args));
29
    }
30
31
    /**
32
     * @override
33
     * @inheritDoc
34
     */
35
    public function geoHash($key, ...$members)
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $members is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        // TODO: Implement geoHash() method.
38
        $command = Enum::GEOHASH;
0 ignored issues
show
Unused Code introduced by
$command is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
39
    }
40
41
    /**
42
     * @override
43
     * @inheritDoc
44
     */
45
    public function geoPos($key, ...$members)
46
    {
47
        // TODO: Implement geoPos() method.
48
        $command = Enum::GEOPOS;
49
        $args = [$key];
50
        $args = array_merge($args, $members);
51
52
        return $this->dispatch(Builder::build($command, $args));
53
    }
54
55
    /**
56
     * @override
57
     * @inheritDoc
58
     */
59
    public function geoDist($key, $memberA, $memberB, $unit)
60
    {
61
        // TODO: Implement geoDist() method.
62
        $command = Enum::GEODIST;
63
        $args = [$key, $memberA, $memberB ,$unit];
64
65
        return $this->dispatch(Builder::build($command, $args));
66
    }
67
68
    /**
69
     * @override
70
     * @inheritDoc
71
     */
72 View Code Duplication
    public function geoRadius($key, $longitude, $latitude, $unit, $command, $count, $sort)
0 ignored issues
show
Unused Code introduced by
The parameter $command is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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...
73
    {
74
        // TODO: Implement geoRadius() method.
75
        $command = Enum::GEORADIUS;
76
        $args = [$key, $longitude, $latitude, $unit, $command, $count, $sort];
77
78
        return $this->dispatch(Builder::build($command, $args));
79
    }
80
81
    /**
82
     * @override
83
     * @inheritDoc
84
     */
85 View Code Duplication
    public function geoRadiusByMember($key, $member, $unit, $command, $count, $sort, $store, $storeDist)
0 ignored issues
show
Unused Code introduced by
The parameter $command is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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...
86
    {
87
        // TODO: Implement geoRadiusByMember() method.
88
        $command = Enum::GEORADIUSBYMEMBER;
89
        $args = [$key, $member, $unit, $command, $count, $sort, $store, $storeDist];
90
91
        return $this->dispatch(Builder::build($command, $args));
92
    }
93
}
94