File tree Expand file tree Collapse file tree 5 files changed +59
-8
lines changed Expand file tree Collapse file tree 5 files changed +59
-8
lines changed Original file line number Diff line number Diff line change @@ -304,8 +304,8 @@ try {
304
304
->setPriorityName("Critical")
305
305
->setIssueType("Bug")
306
306
->setDescription("Full description for issue")
307
- ->addVersion("1.0.1")
308
- ->addVersion("1.0.3" );
307
+ ->addVersion([ "1.0.1", "1.0.3"] )
308
+ ->addComponents(['Component-1', 'Component-2'] );
309
309
310
310
$issueService = new IssueService();
311
311
Original file line number Diff line number Diff line change
1
+ <?php namespace JiraRestApi \Issue ;
2
+
3
+
4
+ class Component implements \JsonSerializable
5
+ {
6
+ public $ id ;
7
+ public $ name ;
8
+
9
+ public function __construct ($ name )
10
+ {
11
+ $ this ->name = $ name ;
12
+ }
13
+
14
+ public function jsonSerialize ()
15
+ {
16
+ return array_filter (get_object_vars ($ this ));
17
+ }
18
+ }
Original file line number Diff line number Diff line change @@ -161,9 +161,13 @@ public function addVersion($name)
161
161
$ this ->versions = array ();
162
162
}
163
163
164
- $ v = new Version ();
165
- $ v ->name = $ name ;
166
- array_push ($ this ->versions , $ v );
164
+ if (is_string ($ name )){
165
+ array_push ($ this ->versions , new Version ($ name ));
166
+ } else if (is_array ($ name )) {
167
+ foreach ($ name as $ v ) {
168
+ array_push ($ this ->versions , new Version ($ v ));
169
+ }
170
+ }
167
171
168
172
return $ this ;
169
173
}
@@ -232,6 +236,30 @@ public function setParent(Issue $parent)
232
236
$ this ->parent = $ parent ;
233
237
}
234
238
239
+ /**
240
+ * add issue component.
241
+ *
242
+ * @param string $component
243
+ *
244
+ * @return $this
245
+ */
246
+ public function addComponents ($ component )
247
+ {
248
+ if (is_null ($ this ->components )) {
249
+ $ this ->components = array ();
250
+ }
251
+
252
+ if (is_string ($ component )){
253
+ array_push ($ this ->components , new Component ($ component ));
254
+ } else if (is_array ($ component )) {
255
+ foreach ($ component as $ c ) {
256
+ array_push ($ this ->components , new Component ($ c ));
257
+ }
258
+ }
259
+
260
+ return $ this ;
261
+ }
262
+
235
263
/** @var string */
236
264
public $ summary ;
237
265
@@ -274,7 +302,7 @@ public function setParent(Issue $parent)
274
302
/** @var string|null */
275
303
public $ environment ;
276
304
277
- /** @var array */
305
+ /** @var \JiraRestApi\Issue\Component[] */
278
306
public $ components ;
279
307
280
308
/** @var Comments */
Original file line number Diff line number Diff line change @@ -25,6 +25,11 @@ class Version implements \JsonSerializable
25
25
/* @var DateTime */
26
26
public $ releaseDate ;
27
27
28
+ public function __construct ($ name )
29
+ {
30
+ $ this ->name = $ name ;
31
+ }
32
+
28
33
public function jsonSerialize ()
29
34
{
30
35
return array_filter (get_object_vars ($ this ));
Original file line number Diff line number Diff line change @@ -36,8 +36,8 @@ public function testCreateIssue()
36
36
->setPriorityName ('Critical ' )
37
37
->setIssueType ('Bug ' )
38
38
->setDescription ('Full description for issue ' )
39
- ->addVersion ('1.0.1 ' )
40
- ->addVersion ( ' 1.0.3 ' )
39
+ ->addVersion ([ '1.0.1 ' , ' 1.0.3 ' ] )
40
+ ->addComponents ([ ' Component-1 ' , ' Component-2 ' ] )
41
41
;
42
42
43
43
$ issueService = new IssueService ();
You can’t perform that action at this time.
0 commit comments