MentionsTimelineQuery::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 15
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 9.4285
cc 1
eloc 13
nc 1
nop 6
crap 1
1
<?php
2
3
namespace Twitter\API\REST\Query\Tweet;
4
5
use Twitter\API\REST\ApiParameters;
6
7
class MentionsTimelineQuery implements ApiParameters
8
{
9
    /** @var int */
10
    private $count;
11
12
    /** @var int */
13
    private $fromId;
14
15
    /** @var int */
16
    private $toId;
17
18
    /** @var bool */
19
    private $includeRetweets;
20
21
    /** @var bool */
22
    private $trimUser;
23
24
    /** @var bool */
25
    private $includeEntities;
26
27
    /**
28
     * MentionsTimelineQuery constructor.
29
     *
30
     * @param int  $count
31
     * @param int  $fromId
32
     * @param int  $toId
33
     * @param bool $includeRetweets
34
     * @param bool $trimUser
35
     * @param bool $includeEntities
36
     */
37 69
    public function __construct(
38
        $count = 20,
39
        $fromId = null,
40
        $toId = null,
41
        $includeRetweets = true,
42
        $trimUser = false,
43
        $includeEntities = true
44
    ) {
45 69
        $this->count = $count;
46 69
        $this->fromId = $fromId;
47 69
        $this->toId = $toId;
48 69
        $this->includeRetweets = $includeRetweets;
49 69
        $this->trimUser = $trimUser;
50 69
        $this->includeEntities = $includeEntities;
51 69
    }
52
53
    /**
54
     * @return array
55
     */
56 9
    public function toArray()
57
    {
58
        $request = [
59 9
            'include_rts' => $this->includeRetweets ? 'true' : 'false',
60 9
            'trim_user' => $this->trimUser ? 'true' : 'false',
61 9
            'include_entities' => $this->includeEntities ? 'true' : 'false'
62 6
        ];
63
64 9
        if ($this->count !== null) {
65 9
            $request['count'] = $this->count;
66 6
        }
67
68 9
        if ($this->fromId !== null) {
69 6
            $request['since_id'] = $this->fromId;
70 4
        }
71
72 9
        if ($this->toId !== null) {
73 6
            $request['max_id'] = $this->toId;
74 4
        }
75
76 9
        return $request;
77
    }
78
}
79