GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b21c26...dc2a23 )
by
unknown
21s queued 17s
created

Comment::getCreatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: andy
5
 * Date: 31.05.17
6
 * Time: 20:56
7
 */
8
9
namespace LPTracker\models;
10
11
use LPTracker\exceptions\LPTrackerSDKException;
12
13
/**
14
 * Class Comment
15
 * @package LPTracker\models
16
 */
17
class Comment extends Model
18
{
19
20
    /**
21
     * @var integer
22
     */
23
    protected $id;
24
25
    /**
26
     * @var string
27
     */
28
    protected $text;
29
30
    /**
31
     * @var integer
32
     */
33
    protected $ownerId;
34
35
    /**
36
     * @var \DateTime
37
     */
38
    protected $createdAt;
39
40
41
    /**
42
     * Comment constructor.
43
     *
44
     * @param array $commentData
45
     */
46
    public function __construct(array $commentData = [])
47
    {
48
        if ( ! empty($commentData['id'])) {
49
            $this->id = intval($commentData['id']);
50
        }
51
        if ( ! empty($commentData['text'])) {
52
            $this->text = $commentData['text'];
53
        }
54
        if ( ! empty($commentData['author'])) {
55
            if ($commentData['author']['type'] == 'main') {
56
                $this->ownerId = 0;
57
            } else {
58
                $this->ownerId = intval($commentData['author']['id']);
59
            }
60
        }
61
        if ( ! empty($commentData['created_at'])) {
62
            $this->setCreatedAt($commentData['created_at']);
63
        }
64
    }
65
66
67
    /**
68
     * @return array
69
     */
70
    public function toArray()
71
    {
72
        return [
73
            'id'         => $this->getId(),
74
            'text'       => $this->getText(),
75
            'owner'      => $this->getOwnerId(),
76
            'created_at' => $this->getCreatedAt()->format('d.m.Y H:i:s')
77
        ];
78
    }
79
80
81
    /**
82
     * @return bool
83
     * @throws LPTrackerSDKException
84
     */
85
    public function validate()
86
    {
87
        if (empty($this->text)) {
88
            throw new LPTrackerSDKException('Text is required');
89
        }
90
91
        return true;
92
    }
93
94
95
    /**
96
     * @return int
97
     */
98
    public function getId()
99
    {
100
        return $this->id;
101
    }
102
103
104
    /**
105
     * @return string
106
     */
107
    public function getText()
108
    {
109
        return $this->text;
110
    }
111
112
113
    /**
114
     * @param string $text
115
     *
116
     * @return $this
117
     */
118
    public function setText($text)
119
    {
120
        $this->text = $text;
121
122
        return $this;
123
    }
124
125
126
    /**
127
     * @return int
128
     */
129
    public function getOwnerId()
130
    {
131
        return $this->ownerId;
132
    }
133
134
135
    /**
136
     * @return \DateTime
137
     */
138
    public function getCreatedAt()
139
    {
140
        return $this->createdAt;
141
    }
142
143
144
    /**
145
     * @param \DateTime $createdAt
146
     *
147
     * @return $this
148
     */
149
    public function setCreatedAt($createdAt)
150
    {
151
        if ( ! $createdAt instanceof \DateTime) {
152
            $createdAt = \DateTime::createFromFormat('d.m.Y H:i:s', $createdAt);
153
        }
154
        $this->createdAt = $createdAt;
155
156
        return $this;
157
    }
158
}