Tweet::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 15
nc 1
nop 7
1
<?php namespace Tuiter;
2
3
/**
4
 * Class Tweet
5
 * @package Tuiter
6
 */
7
final class Tweet
8
{
9
    /**
10
     * @var
11
     */
12
    public $id;
13
14
    /**
15
     * @var
16
     */
17
    public $text;
18
19
    /**
20
     * @var
21
     */
22
    public $source;
23
24
    /**
25
     * @var \DateTime
26
     */
27
    public $createdAt;
28
29
    /**
30
     * @var null
31
     */
32
    public $inReplyToStatusId;
33
34
    /**
35
     * @var null
36
     */
37
    public $retweetedStatusId;
38
39
    /**
40
     * @var array
41
     */
42
    public $expandedUrls;
43
44
    /**
45
     * @param $id
46
     * @param $text
47
     * @param $source
48
     * @param $createdAt
49
     * @param null $inReplyToStatusId
50
     * @param null $retweetedStatusId
51
     * @param null $expandedUrls
52
     */
53
    public function __construct(
54
        $id,
55
        $text,
56
        $source,
57
        $createdAt,
58
        $inReplyToStatusId = null,
59
        $retweetedStatusId = null,
60
        $expandedUrls = null
61
    ) {
62
        $this->id = $id;
63
        $this->text = $text;
64
        $this->source = $source;
65
        $this->createdAt = new \DateTime($createdAt);
66
        $this->inReplyToStatusId = $inReplyToStatusId;
67
        $this->retweetedStatusId = $retweetedStatusId;
68
        $this->expandedUrls = explode(',', $expandedUrls);
69
    }
70
71
    /**
72
     * @return bool
73
     */
74
    public function isRetweet()
75
    {
76
        return $this->retweetedStatusId !== null;
77
    }
78
79
    /**
80
     * @return bool
81
     */
82
    public function isReply()
83
    {
84
        return $this->inReplyToStatusId !== null;
85
    }
86
87
}
88