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

SentDirectMessageQuery::toArray()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

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