This repository was archived by the owner on Jul 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Manavo \DoneDone ;
4+
5+ class Comment
6+ {
7+
8+ /**
9+ * @var string
10+ */
11+ private $ message = null ;
12+
13+ /**
14+ * @var array
15+ */
16+ private $ attachments = [];
17+
18+ /**
19+ * @param string $attachment
20+ */
21+ public function addAttachment ($ attachment )
22+ {
23+ $ this ->attachments [] = $ attachment ;
24+ }
25+
26+ /**
27+ * @param string $message
28+ */
29+ public function setMessage ($ message )
30+ {
31+ $ this ->message = $ message ;
32+ }
33+
34+ /**
35+ * @return array
36+ */
37+ public function toArray ()
38+ {
39+ $ data = [
40+ 'comment ' => $ this ->message ,
41+ ];
42+
43+ foreach ($ this ->attachments as $ index => $ attachment ) {
44+ $ data ['attachment- ' . $ index ] = fopen ($ attachment , 'r ' );
45+ }
46+
47+ return $ data ;
48+ }
49+
50+ }
Original file line number Diff line number Diff line change 44
55class Issue
66{
7+ /**
8+ * @var Client
9+ */
10+ private $ client ;
11+
12+ /**
13+ * @var int
14+ */
15+ private $ projectId ;
16+
17+ /**
18+ * @var int
19+ */
20+ private $ id ;
21+
722 private $ title = null ;
823 private $ priorityLevel = null ;
924 private $ fixer = null ;
@@ -14,6 +29,18 @@ class Issue
1429 private $ userIdsToCc = null ;
1530 private $ tags = null ;
1631
32+ /**
33+ * @param Client $client
34+ * @param int $projectId
35+ * @param int $id
36+ */
37+ function __construct ($ client , $ projectId , $ id )
38+ {
39+ $ this ->client = $ client ;
40+ $ this ->projectId = $ projectId ;
41+ $ this ->id = $ id ;
42+ }
43+
1744 /**
1845 * @param string $description
1946 */
@@ -109,6 +136,25 @@ public function setTags($tags)
109136 $ this ->tags = $ tags ;
110137 }
111138
139+ /**
140+ * Add a new comment to the issue
141+ *
142+ * @param Comment $comment
143+ *
144+ * @return array
145+ */
146+ public function addComment ($ comment )
147+ {
148+ return $ this ->client ->post (
149+ sprintf (
150+ 'projects/%d/issues/%d/comments ' ,
151+ $ this ->projectId ,
152+ $ this ->id
153+ ),
154+ $ comment ->toArray ()
155+ );
156+ }
157+
112158 /**
113159 * @return array
114160 */
Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ public function issues()
4545 return $ this ->client ->get ('projects/ ' . $ this ->id . '/issues/all ' );
4646 }
4747
48+ public function issue ($ id )
49+ {
50+ return new Issue ($ this ->client , $ this ->id , $ id );
51+ }
52+
4853 /**
4954 * Get all the active issues associated with this project
5055 *
You can’t perform that action at this time.
0 commit comments