ReverseGeoCode::callback()   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/id/place_id
9
 */
10
class ReverseGeoCode extends BaseRequest
11
{
12
    const METHOD   = 'GET';
13
    const ENDPOINT = '/geo/reverse_geocode.json';
14
15
    // we use string type declaration instead of float, because of precision platform independence
16 7
    public function __construct(string $latitude, string $longitude)
17
    {
18 7
        parent::__construct(self::METHOD, self::ENDPOINT);
19
20 7
        $this->parameters['lat']  = $latitude;
21 7
        $this->parameters['long'] = $longitude;
22
    }
23
24 1
    public function accuracy(string $accuracy): ReverseGeoCode
25
    {
26 1
        $this->parameters['accuracy'] = $accuracy;
27
28 1
        return $this;
29
    }
30
31 2 View Code Duplication
    public function granularity(string $granularity): ReverseGeoCode
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...
32
    {
33 2
        if (!in_array($granularity, ['poi', 'neighborhood', 'city', 'admin', 'county'], true)) {
34 1
            throw new InvalidGranularityException();
35
        }
36
37 1
        $this->parameters['granularity'] = $granularity;
38
39 1
        return $this;
40
    }
41
42 1
    public function amount(int $amount): ReverseGeoCode
43
    {
44 1
        $this->parameters['max_results'] = (string) $amount;
45
46 1
        return $this;
47
    }
48
49 1
    public function callback(string $callback): ReverseGeoCode
50
    {
51 1
        $this->parameters['callback'] = $callback;
52
53 1
        return $this;
54
    }
55
}
56