Passed
Push — master ( e8c85a...007af2 )
by Daniel
02:09
created

MergeRequest::isClosed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace DanielPieper\MergeReminder\ValueObject;
4
5
class MergeRequest
6
{
7
    public const STATE_OPENED = 'opened';
8
    public const STATE_CLOSED = 'closed';
9
    public const STATE_LOCKED = 'locked';
10
    public const STATE_MERGED = 'merged';
11
12
    /** @var int */
13
    private $id;
14
15
    /** @var int */
16
    private $iid;
17
18
    /** @var string */
19
    private $title;
20
21
    /** @var string */
22
    private $description;
23
24
    /** @var string */
25
    private $webUrl;
26
27
    /** @var bool */
28
    private $isWorkInProgress;
29
30
    /** @var Project */
31
    private $project;
32
33
    /** @var User */
34
    private $author;
35
36
    /** @var User */
37
    private $assignee;
38
39
    /**
40
     * Project constructor.
41
     * @param int $id
42
     * @param int $iid
43
     * @param string $title
44
     * @param string $description
45
     * @param string $webUrl
46
     * @param bool $isWorkInProgress
47
     * @param Project $project
48
     * @param User $author
49
     * @param User $assignee
50
     *
51
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
52
     */
53 37
    public function __construct(
54
        int $id,
55
        int $iid,
56
        string $title,
57
        string $description,
58
        string $webUrl,
59
        bool $isWorkInProgress,
60
        Project $project,
61
        User $author,
62
        ?User $assignee = null
63
    ) {
64 37
        $this->id = $id;
65 37
        $this->iid = $iid;
66 37
        $this->title = $title;
67 37
        $this->description = $description;
68 37
        $this->webUrl = $webUrl;
69 37
        $this->isWorkInProgress = $isWorkInProgress;
70 37
        $this->project = $project;
71 37
        $this->author = $author;
72 37
        $this->assignee = $assignee;
73 37
    }
74
75
    /**
76
     * @param array $mergeRequest
77
     * @return MergeRequest
78
     */
79 37
    public static function fromArray(array $mergeRequest): self
80
    {
81 37
        return new self(
82 37
            (int)$mergeRequest['id'],
83 37
            (int)$mergeRequest['iid'],
84 37
            (string)$mergeRequest['title'],
85 37
            (string)$mergeRequest['description'],
86 37
            (string)$mergeRequest['web_url'],
87 37
            (bool)$mergeRequest['work_in_progress'],
88 37
            $mergeRequest['project'],
89 37
            $mergeRequest['author'],
90 37
            $mergeRequest['assignee']
91
        );
92
    }
93
94
    /**
95
     * @return int
96
     */
97 9
    public function getIid(): int
98
    {
99 9
        return $this->iid;
100
    }
101
102
    /**
103
     * @return int
104
     */
105 1
    public function getId(): int
106
    {
107 1
        return $this->id;
108
    }
109
110
    /**
111
     * @return string
112
     */
113 4
    public function getTitle(): string
114
    {
115 4
        return $this->title;
116
    }
117
118
    /**
119
     * @return string
120
     */
121 3
    public function getDescription(): string
122
    {
123 3
        return $this->description;
124
    }
125
126
    /**
127
     * @return string
128
     */
129 4
    public function getWebUrl(): string
130
    {
131 4
        return $this->webUrl;
132
    }
133
134
    /**
135
     * @return Project
136
     */
137 12
    public function getProject(): Project
138
    {
139 12
        return $this->project;
140
    }
141
142
    /**
143
     * @return User
144
     */
145 4
    public function getAuthor(): User
146
    {
147 4
        return $this->author;
148
    }
149
150
    /**
151
     * @return User|null
152
     */
153 4
    public function getAssignee(): ?User
154
    {
155 4
        return $this->assignee;
156
    }
157
158
    /**
159
     * @return bool
160
     */
161 9
    public function isWorkInProgress(): bool
162
    {
163 9
        return $this->isWorkInProgress;
164
    }
165
}
166