File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Expand file tree Collapse file tree 3 files changed +44
-1
lines changed 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 @@ -232,6 +232,30 @@ public function setParent(Issue $parent)
232
232
$ this ->parent = $ parent ;
233
233
}
234
234
235
+ /**
236
+ * add issue component.
237
+ *
238
+ * @param string $component
239
+ *
240
+ * @return $this
241
+ */
242
+ public function addComponents ($ component )
243
+ {
244
+ if (is_null ($ this ->components )) {
245
+ $ this ->components = array ();
246
+ }
247
+
248
+ if (is_string ($ component )){
249
+ array_push ($ this ->components , new Component ($ component ));
250
+ } else if (is_array ($ component )) {
251
+ foreach ($ component as $ c ) {
252
+ array_push ($ this ->components , new Component ($ c ));
253
+ }
254
+ }
255
+
256
+ return $ this ;
257
+ }
258
+
235
259
/** @var string */
236
260
public $ summary ;
237
261
@@ -274,7 +298,7 @@ public function setParent(Issue $parent)
274
298
/** @var string|null */
275
299
public $ environment ;
276
300
277
- /** @var array */
301
+ /** @var \JiraRestApi\Issue\Component[] */
278
302
public $ components ;
279
303
280
304
/** @var Comments */
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ public function testCreateIssue()
38
38
->setDescription ('Full description for issue ' )
39
39
->addVersion ('1.0.1 ' )
40
40
->addVersion ('1.0.3 ' )
41
+ ->addComponents (['Component-1 ' , 'Component-2 ' ])
41
42
;
42
43
43
44
$ issueService = new IssueService ();
You can’t perform that action at this time.
0 commit comments