Passed
Pull Request — master (#346)
by
unknown
02:42
created

RequestComment::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace JiraRestApi\Request;
4
5
class RequestComment implements \JsonSerializable
6
{
7
    /** @var string */
8
    public $id;
9
10
    /** @var string */
11
    public $body;
12
13
    /** @var bool */
14
    public $public;
15
16
    /** @var \JiraRestApi\Request\Author */
17
    public $author;
18
19
    /** @var \DateTimeInterface */
20
    public $created;
21
22
    /**
23
     * @param string $body
24
     *
25
     * @return $this
26
     */
27
    public function setBody(string $body)
28
    {
29
        $this->body = $body;
30
31
        return $this;
32
    }
33
34
    /**
35
     * @param bool $public True for is public, false otherwise
36
     * @return $this
37
     */
38
    public function setIsPublic(bool $public)
39
    {
40
        $this->public = $public;
41
        return $this;
42
    }
43
44
    public function jsonSerialize()
45
    {
46
        return array_filter(get_object_vars($this), function ($var) {
47
            return $var !== null;
48
        });
49
    }
50
}
51