Completed
Push — master ( 97ed41...46628b )
by Rémi
04:52
created

DirectMessageQuery::toArray()   B

Complexity

Conditions 6
Paths 32

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 6

Importance

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