SentDirectMessageQuery   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 65
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
B toArray() 0 21 5
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 63
    public function __construct(
34
        $count = 20,
35
        $fromId = null,
36
        $toId = null,
37
        $includeEntities = true,
38
        $page = 1
39
    ) {
40 63
        $this->count = $count;
41 63
        $this->fromId = $fromId;
42 63
        $this->toId = $toId;
43 63
        $this->includeEntities = $includeEntities;
44 63
        $this->page = $page;
45 63
    }
46
47
    /**
48
     * @return array
49
     */
50 9
    public function toArray()
51
    {
52
        $request = [
53 9
            'include_entities' => $this->includeEntities ? 'true' : 'false',
54 9
            'page' => $this->page
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