Issue::getStatus()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of the GithubIssueBundle package.
4
 *
5
 * (c) Paul Schweppe <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace VersionControl\GithubIssueBundle\Entity\Issues;
12
13
use VersionControl\GitControlBundle\Entity\Issues\IssueInterface;
14
15
class Issue implements IssueInterface
16
{
17
    /**
18
     * @var string
19
     */
20
    private $title;
21
22
    /**
23
     * @var string
24
     */
25
    private $description;
26
27
    /**
28
     * State of issue.
29
     *
30
     * @var string
31
     */
32
    private $status;
33
34
    /**
35
     * @var \DateTime
36
     */
37
    private $closedAt;
38
39
    /**
40
     * @var \DateTime
41
     */
42
    private $createdAt;
43
44
    /**
45
     * @var \DateTime
46
     */
47
    private $updatedAt;
48
49
    /**
50
     * @var int
51
     */
52
    private $githubNumber;
53
54
    /**
55
     * @var int
56
     */
57
    private $id;
58
59
    /**
60
     * @var \VersionControl\GithubIssueBundle\Entity\Issues\IssueMilestone
61
     */
62
    private $issueMilestone;
63
64
    /**
65
     * @var \VersionControl\GithubIssueBundle\Entity\User
66
     */
67
    private $user;
68
69
    /**
70
     * @var array
71
     */
72
    private $issueLabel;
73
74
    /**
75
     * Issue comments.
76
     *
77
     * @var array
78
     */
79
    private $issueComments;
80
81
    /**
82
     * Constructor.
83
     */
84
    public function __construct()
85
    {
86
        $this->issueLabel = array();
87
        $this->issueComments = array();
88
        $this->setCreatedAt(new \DateTime());
89
        $this->setStatus('open');
90
    }
91
92
    public function setId($id)
93
    {
94
        $this->id = $id;
95
96
        return $this;
97
    }
98
99
    /**
100
     * Set title.
101
     *
102
     * @param string $title
103
     *
104
     * @return Issue
105
     */
106
    public function setTitle($title)
107
    {
108
        $this->title = $title;
109
110
        return $this;
111
    }
112
113
    /**
114
     * Get title.
115
     *
116
     * @return string
117
     */
118
    public function getTitle()
119
    {
120
        return $this->title;
121
    }
122
123
    /**
124
     * Set description.
125
     *
126
     * @param string $description
127
     *
128
     * @return Issue
129
     */
130
    public function setDescription($description)
131
    {
132
        $this->description = $description;
133
134
        return $this;
135
    }
136
137
    /**
138
     * Get description.
139
     *
140
     * @return string
141
     */
142
    public function getDescription()
143
    {
144
        return $this->description;
145
    }
146
147
    /**
148
     * Set status.
149
     *
150
     * @param string $status
151
     *
152
     * @return Issue
153
     */
154
    public function setStatus($status)
155
    {
156
        $this->status = $status;
157
158
        return $this;
159
    }
160
161
    /**
162
     * Get status.
163
     *
164
     * @return string
165
     */
166
    public function getStatus()
167
    {
168
        return $this->status;
169
    }
170
171
    /**
172
     * Set closedAt.
173
     *
174
     * @param \DateTime $closedAt
175
     *
176
     * @return Issue
177
     */
178
    public function setClosedAt($closedAt)
179
    {
180
        $this->closedAt = $closedAt;
181
182
        return $this;
183
    }
184
185
    /**
186
     * Get closedAt.
187
     *
188
     * @return \DateTime
189
     */
190
    public function getClosedAt()
191
    {
192
        return $this->closedAt;
193
    }
194
195
    /**
196
     * Set createdAt.
197
     *
198
     * @param \DateTime $createdAt
199
     *
200
     * @return Issue
201
     */
202
    public function setCreatedAt($createdAt)
203
    {
204
        $this->createdAt = $createdAt;
205
206
        return $this;
207
    }
208
209
    /**
210
     * Get createdAt.
211
     *
212
     * @return \DateTime
213
     */
214
    public function getCreatedAt()
215
    {
216
        return $this->createdAt;
217
    }
218
219
    /**
220
     * Set updatedAt.
221
     *
222
     * @param \DateTime $updatedAt
223
     *
224
     * @return Issue
225
     */
226
    public function setUpdatedAt($updatedAt)
227
    {
228
        $this->updatedAt = $updatedAt;
229
230
        return $this;
231
    }
232
233
    /**
234
     * Get updatedAt.
235
     *
236
     * @return \DateTime
237
     */
238
    public function getUpdatedAt()
239
    {
240
        return $this->updatedAt;
241
    }
242
243
    /**
244
     * Set githubNumber.
245
     *
246
     * @param int $githubNumber
247
     *
248
     * @return Issue
249
     */
250
    public function setGithubNumber($githubNumber)
251
    {
252
        $this->githubNumber = $githubNumber;
253
254
        return $this;
255
    }
256
257
    /**
258
     * Get githubNumber.
259
     *
260
     * @return int
261
     */
262
    public function getGithubNumber()
263
    {
264
        return $this->githubNumber;
265
    }
266
267
    /**
268
     * Get id.
269
     *
270
     * @return int
271
     */
272
    public function getId()
273
    {
274
        return $this->id;
275
    }
276
277
    /**
278
     * Set issueMilestone.
279
     *
280
     * @param \VersionControl\GithubIssueBundle\Entity\Issues\IssueMilestone $issueMilestone
281
     *
282
     * @return Issue
283
     */
284
    public function setIssueMilestone(\VersionControl\GithubIssueBundle\Entity\Issues\IssueMilestone $issueMilestone = null)
285
    {
286
        $this->issueMilestone = $issueMilestone;
287
288
        return $this;
289
    }
290
291
    /**
292
     * Get issueMilestone.
293
     *
294
     * @return \VersionControl\GithubIssueBundle\Entity\Issues\IssueMilestone
295
     */
296
    public function getIssueMilestone()
297
    {
298
        return $this->issueMilestone;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->issueMilestone returns the type VersionControl\GithubIss...y\Issues\IssueMilestone which is incompatible with the return type mandated by VersionControl\GitContro...ce::getIssueMilestone() of VersionControl\GitContro...e\Entity\IssueMilestone.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
299
    }
300
301
    /**
302
     * Set User.
303
     *
304
     * @param \VersionControl\GithubIssueBundle\Entity\User $user
305
     *
306
     * @return Issue
307
     */
308
    public function setUser(\VersionControl\GithubIssueBundle\Entity\User $user = null)
309
    {
310
        $this->user = $user;
311
312
        return $this;
313
    }
314
315
    /**
316
     * Get User.
317
     *
318
     * @return \VersionControl\GithubIssueBundle\Entity\User
319
     */
320
    public function getUser()
321
    {
322
        return $this->user;
323
    }
324
325
    /**
326
     * Add issueLabel.
327
     *
328
     * @param \VersionControl\GithubIssueBundle\Entity\Issues\IssueLabel $issueLabel
329
     *
330
     * @return Issue
331
     */
332
    public function addIssueLabel(\VersionControl\GithubIssueBundle\Entity\Issues\IssueLabel $issueLabel)
333
    {
334
        $this->issueLabel[] = $issueLabel;
335
336
        return $this;
337
    }
338
339
    /**
340
     * Remove issueLabel.
341
     *
342
     * @param \VersionControl\GithubIssueBundle\Entity\Issues\IssueLabel $issueLabel
343
     */
344
    public function removeIssueLabel(\VersionControl\GithubIssueBundle\Entity\Issues\IssueLabel $issueLabel)
345
    {
346
        $key = array_search($issueLabel, $this->issueLabel, true);
347
        if ($key !== false) {
348
            unset($this->issueLabel[$key]);
349
        }
350
    }
351
352
    /**
353
     * Get issueLabel.
354
     *
355
     * @return array
356
     */
357
    public function getIssueLabel()
358
    {
359
        return $this->issueLabel;
360
    }
361
362
    /**
363
     * Add Issue Comment.
364
     *
365
     * @param \VersionControl\GithubIssueBundle\Entity\Issues\IssueComment $issueComment
366
     *
367
     * @return Issue
368
     */
369
    public function addIssueComment(\VersionControl\GithubIssueBundle\Entity\Issues\IssueComment $issueComment)
370
    {
371
        $this->issueComments[] = $issueComment;
372
373
        return $this;
374
    }
375
376
    /**
377
     * Get Issue Comments.
378
     *
379
     * @return array of \VersionControl\GitControlBundle\Entity\Issue\IssueComment
380
     */
381
    public function getIssueComments()
382
    {
383
        return $this->issueComments;
384
    }
385
386
    /**
387
     * Set Issue Comments.
388
     *
389
     * @param array $issueComments
390
     *
391
     * @return \VersionControl\GitControlBundle\Entity\Issue
392
     */
393
    public function setIssueComments(array $issueComments)
394
    {
395
        $this->issueComments = $issueComments;
396
397
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type VersionControl\GithubIss...dle\Entity\Issues\Issue which is incompatible with the documented return type VersionControl\GitControlBundle\Entity\Issue.
Loading history...
398
    }
399
400
    /**
401
     * Set status.
402
     *
403
     * @param string $status
404
     *
405
     * @return Issue
406
     */
407
    public function setClosed()
408
    {
409
        $this->status = 'closed';
410
411
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type VersionControl\GithubIss...dle\Entity\Issues\Issue which is incompatible with the return type mandated by VersionControl\GitContro...eInterface::setClosed() of VersionControl\GitContro...dle\Entity\Issues\Issue.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
412
    }
413
414
    /**
415
     * Set status.
416
     *
417
     * @param string $status
418
     *
419
     * @return Issue
420
     */
421
    public function setOpen()
422
    {
423
        $this->status = 'open';
424
425
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type VersionControl\GithubIss...dle\Entity\Issues\Issue which is incompatible with the return type mandated by VersionControl\GitContro...sueInterface::setOpen() of VersionControl\GitContro...dle\Entity\Issues\Issue.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
426
    }
427
428
    public function isClosed()
429
    {
430
        return ($this->status === 'closed') ? true : false;
431
    }
432
}
433