Search   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 84
Duplicated Lines 11.9 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 2
dl 10
loc 84
ccs 34
cts 34
cp 1
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A latitude() 0 6 1
A longitude() 0 6 1
A query() 0 6 1
A ip() 0 6 1
A granularity() 10 10 2
A accuracy() 0 6 1
A amount() 0 6 1
A containedWithin() 0 6 1
A streetAddress() 0 6 1
A callback() 0 6 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 declare(strict_types=1);
2
3
namespace PeeHaa\AsyncTwitter\Api\Request\Geo;
4
5
use PeeHaa\AsyncTwitter\Api\Request\BaseRequest;
6
7
/**
8
 * @link https://dev.twitter.com/rest/reference/get/geo/search
9
 */
10
class Search extends BaseRequest
11
{
12
    const METHOD   = 'GET';
13
    const ENDPOINT = '/geo/search.json';
14
15 11
    public function __construct()
16
    {
17 11
        parent::__construct(self::METHOD, self::ENDPOINT);
18
    }
19
20 1
    public function latitude(string $latitude): Search
21
    {
22 1
        $this->parameters['lat'] = $latitude;
23
24 1
        return $this;
25
    }
26
27 1
    public function longitude(string $longitude): Search
28
    {
29 1
        $this->parameters['long'] = $longitude;
30
31 1
        return $this;
32
    }
33
34 1
    public function query(string $query): Search
35
    {
36 1
        $this->parameters['query'] = $query;
37
38 1
        return $this;
39
    }
40
41 1
    public function ip(string $ip): Search
42
    {
43 1
        $this->parameters['ip'] = $ip;
44
45 1
        return $this;
46
    }
47
48 2 View Code Duplication
    public function granularity(string $granularity): Search
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...
49
    {
50 2
        if (!in_array($granularity, ['poi', 'neighborhood', 'city', 'admin', 'county'], true)) {
51 1
            throw new InvalidGranularityException();
52
        }
53
54 1
        $this->parameters['granularity'] = $granularity;
55
56 1
        return $this;
57
    }
58
59 1
    public function accuracy(string $accuracy): Search
60
    {
61 1
        $this->parameters['accuracy'] = $accuracy;
62
63 1
        return $this;
64
    }
65
66 1
    public function amount(int $amount): Search
67
    {
68 1
        $this->parameters['max_results'] = (string) $amount;
69
70 1
        return $this;
71
    }
72
73 1
    public function containedWithin(string $placeId): Search
74
    {
75 1
        $this->parameters['contained_within'] = $placeId;
76
77 1
        return $this;
78
    }
79
80 1
    public function streetAddress(string $address): Search
81
    {
82 1
        $this->parameters['attribute:street_address'] = $address;
83
84 1
        return $this;
85
    }
86
87 1
    public function callback(string $callback): Search
88
    {
89 1
        $this->parameters['callback'] = $callback;
90
91 1
        return $this;
92
    }
93
}
94