Search::amount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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