Completed
Pull Request — master (#10)
by
unknown
03:09
created

Search::locale()   A

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 0
crap 1
1
<?php declare(strict_types=1);
2
3
namespace PeeHaa\AsyncTwitter\Api\Request\Search;
4
5
use PeeHaa\AsyncTwitter\Api\Request\BaseRequest;
6
7
/**
8
 * @link https://dev.twitter.com/rest/reference/get/search/tweets
9
 */
10
class Search extends BaseRequest
11
{
12
    const METHOD         = 'GET';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 9 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
13
    const ENDPOINT       = '/search/tweets.json';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 1 space but found 7 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
14
15
    private $resultTypes = ['mixed', 'recent', 'popular'];
16
17 19
    public function __construct(string $searchString)
18
    {
19 19
        parent::__construct(self::METHOD, self::ENDPOINT);
20
21 19
        $this->parameters['q'] = $searchString;
22
    }
23
24
    //use string instead of float
25 2
    public function geocode(string $latitude, string $longitude, string $radius): Search
26
    {
27 2
        $this->parameters['geocode'] = sprintf('%s %s %s', $latitude, $longitude, $radius);
28
29 2
        return $this;
30
    }
31
32 2
    public function language(string $language = 'en'): Search
33
    {
34 2
        $this->parameters['lang'] = $language;
35
36 2
        return $this;
37
    }
38
39 2
    public function locale(): Search
40
    {
41 2
        $this->parameters['locale'] = 'ja';
42
43 2
        return $this;
44
    }
45
46 2
    public function resultType(string $resultType): Search
47
    {
48 2
        if (in_array($resultType, $this->resultTypes)) {
49 2
            $this->parameters['result_type'] = $resultType;
50
        }
51
52 2
        return $this;
53
    }
54
55 2
    public function amount(int $amount): Search
56
    {
57 2
        $this->parameters['count'] = (string) $amount;
58
59 2
        return $this;
60
    }
61
62 2
    public function until(\DateTime $until): Search
63
    {
64 2
        $this->parameters['until'] = $until->format('Y-m-d');
65
66 2
        return $this;
67
    }
68
69 2
    public function minimumId(int $id): Search
70
    {
71 2
        $this->parameters['since_id'] = (string) $id;
72
73 2
        return $this;
74
    }
75
76 2
    public function maximumId(int $id): Search
77
    {
78 2
        $this->parameters['max_id'] = (string) $id;
79
80 2
        return $this;
81
    }
82
83 2
    public function excludeEntities(): Search
84
    {
85 2
        $this->parameters['include_entities'] = 'false';
86
87 2
        return $this;
88
    }
89
}
90