Completed
Push — master ( d83f32...d4821e )
by Rémi
04:29
created

MentionsTimelineQuery::toArray()   C

Complexity

Conditions 7
Paths 64

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 7.9295

Importance

Changes 0
Metric Value
dl 0
loc 22
c 0
b 0
f 0
ccs 11
cts 15
cp 0.7332
rs 6.9811
cc 7
eloc 12
nc 64
nop 0
crap 7.9295
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 12
    public function __construct(
38
        $count = 20,
39
        $fromId = null,
40
        $toId = null,
41
        $includeRetweets = true,
42
        $trimUser = false,
43
        $includeEntities = true
44
    ) {
45 12
        $this->count = $count;
46 12
        $this->fromId = $fromId;
47 12
        $this->toId = $toId;
48 12
        $this->includeRetweets = $includeRetweets;
49 12
        $this->trimUser = $trimUser;
50 12
        $this->includeEntities = $includeEntities;
51 12
    }
52
53
    /**
54
     * @return array
55
     */
56 3
    public function toArray()
57
    {
58
        $request = [
59 3
            'include_rts' => $this->includeRetweets ? 'true' : 'false',
60 3
            'trim_user' => $this->trimUser ? 'true' : 'false',
61 3
            'include_entities' => $this->includeEntities ? 'true' : 'false'
62 2
        ];
63
64 3
        if ($this->count !== null) {
65 3
            $request['count'] = $this->count;
66 2
        }
67
68 3
        if ($this->fromId !== null) {
69
            $request['since_id'] = $this->fromId;
70
        }
71
72 3
        if ($this->toId !== null) {
73
            $request['max_id'] = $this->toId;
74
        }
75
76 3
        return $request;
77
    }
78
}
79