Passed
Push — master ( 481bab...3500c6 )
by KwangSeob
02:27
created

Transition::setUntranslatedName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 2
eloc 3
c 1
b 1
f 1
nc 2
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
namespace JiraRestApi\Issue;
4
5
/**
6
 * Issue Transition mapping class.
7
 */
8
class Transition implements \JsonSerializable
9
{
10
    /** @var string */
11
    public $id;
12
13
    /** @var string */
14
    public $name;
15
16
    /** @var \JiraRestApi\Issue\TransitionTo */
17
    public $to;
18
19
    /** @var array */
20
    public $fields;
21
22
    /** @var \JiraRestApi\Issue\IssueField */
23
    public $issueFields;
24
25
    /** @var array */
26
    public $transition;
27
28
    /** @var array */
29
    public $update;
30
31
    public function setTransitionName($name)
32
    {
33
        if (is_null($this->transition)) {
0 ignored issues
show
introduced by
The condition is_null($this->transition) is always false.
Loading history...
34
            $this->transition = [];
35
        }
36
37
        $this->transition['name'] = $name;
38
    }
39
40
    /**
41
     * set none translated transition name
42
     *
43
     * @param string $untranslatedName
44
     */
45
    public function setUntranslatedName(string $untranslatedName)
46
    {
47
        if (is_null($this->transition)) {
0 ignored issues
show
introduced by
The condition is_null($this->transition) is always false.
Loading history...
48
            $this->transition = [];
49
        }
50
51
        $this->transition['untranslatedName'] = $untranslatedName;
52
    }
53
54
    public function setTransitionId($id)
55
    {
56
        if (is_null($this->transition)) {
0 ignored issues
show
introduced by
The condition is_null($this->transition) is always false.
Loading history...
57
            $this->transition = [];
58
        }
59
60
        $this->transition['id'] = $id;
61
    }
62
63
    public function setCommentBody($commentBody)
64
    {
65
        if (is_null($this->update)) {
0 ignored issues
show
introduced by
The condition is_null($this->update) is always false.
Loading history...
66
            $this->update = [];
67
            $this->update['comment'] = [];
68
        }
69
70
        $ar = [];
71
        $ar['add']['body'] = $commentBody;
72
        array_push($this->update['comment'], $ar);
73
    }
74
75
    public function jsonSerialize()
76
    {
77
        return array_filter(get_object_vars($this));
78
    }
79
}
80