Test Failed
Push — master ( 628e98...a0d58b )
by Pieter
03:08
created

ReverseGeoCode::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php declare(strict_types=1);
2
3
namespace PeeHaa\AsyncTwitter\Api\Request\Geo;
4
5
use PeeHaa\AsyncTwitter\Api\Request\BaseRequest;
6
7
class ReverseGeoCode extends BaseRequest
8
{
9
    const METHOD   = 'GET';
10
    const ENDPOINT = '/geo/reverse_geocode.json';
11
12
    // we use string type declaration instead of float, because of precision platform independence
13
    public function __construct(string $latitude, string $longitude)
14
    {
15
        parent::__construct(self::METHOD, self::ENDPOINT);
16
17
        $this->parameters['lat']  = $latitude;
18
        $this->parameters['long'] = $longitude;
19
    }
20
21
    public function accuracy(string $accuracy): ReverseGeoCode
22
    {
23
        $this->parameters['accuracy'] = $accuracy;
24
25
        return $this;
26
    }
27
28 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...
29
    {
30
        if (!in_array($granularity, ['poi', 'neighborhood', 'city', 'admin', 'county'], true)) {
31
            throw new InvalidGranularityException();
32
        }
33
34
        $this->parameters['granularity'] = $granularity;
35
36
        return $this;
37
    }
38
39
    public function amount(int $amount): ReverseGeoCode
40
    {
41
        $this->parameters['max_results'] = (string) $amount;
42
43
        return $this;
44
    }
45
46
    public function callback(string $callback): ReverseGeoCode
47
    {
48
        $this->parameters['callback'] = $callback;
49
50
        return $this;
51
    }
52
}
53