Repository navigation
Expand file tree
/
Copy pathIssue.php
More file actions
263 lines (240 loc) · 7.57 KB
/
Copy pathIssue.php
File metadata and controls
263 lines (240 loc) · 7.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<?php
namespace Github\Api;
use Github\Api\Issue\Assignees;
use Github\Api\Issue\Comments;
use Github\Api\Issue\Events;
use Github\Api\Issue\Labels;
use Github\Api\Issue\Milestones;
use Github\Api\Issue\Timeline;
use Github\Exception\MissingArgumentException;
/**
* Listing issues, searching, editing and closing your projects issues.
*
* @link http://develop.github.com/p/issues.html
*
* @author Thibault Duplessis <thibault.duplessis at gmail dot com>
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class Issue extends AbstractApi
{
use AcceptHeaderTrait;
/**
* Configure the body type.
*
* @link https://developer.github.com/v3/issues/#custom-media-types
*
* @param string|null $bodyType
*
* @return self
*/
public function configure($bodyType = null)
{
if (!in_array($bodyType, ['text', 'html', 'full'])) {
$bodyType = 'raw';
}
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->client->getApiVersion(), $bodyType);
return $this;
}
/**
* List issues by username, repo and state.
*
* @link http://developer.github.com/v3/issues/
*
* @param string $username the username
* @param string $repository the repository
* @param array $params the additional parameters like milestone, assignees, labels, sort, direction
*
* @return array list of issues found
*/
public function all($username, $repository, array $params = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues', array_merge(['page' => 1], $params));
}
/**
* Search issues by username, repo, state and keyword.
*
* @deprecated This method is deprecated use the Search api instead. See https://developer.github.com/v3/search/legacy/#legacy-search-api-is-deprecated
* @link http://developer.github.com/v3/search/#search-issues
*
* @param string $username the username
* @param string $repository the repository
* @param string $state the issue state, can be open or closed
* @param string $keyword the keyword to filter issues by
*
* @return array list of issues found
*/
public function find($username, $repository, $state, $keyword)
{
if (!in_array($state, ['open', 'closed'])) {
$state = 'open';
}
return $this->get('/legacy/issues/search/'.rawurlencode($username).'/'.rawurlencode($repository).'/'.rawurlencode($state).'/'.rawurlencode($keyword));
}
/**
* List issues by organization.
*
* @link http://developer.github.com/v3/issues/
*
* @param string $organization the organization
* @param string $state the issue state, can be open or closed
* @param array $params the additional parameters like milestone, assignees, labels, sort, direction
*
* @return array list of issues found
*/
public function org($organization, $state, array $params = [])
{
if (!in_array($state, ['open', 'closed'])) {
$state = 'open';
}
return $this->get('/orgs/'.rawurlencode($organization).'/issues', array_merge(['page' => 1, 'state' => $state], $params));
}
/**
* Get extended information about an issue by its username, repo and number.
*
* @link http://developer.github.com/v3/issues/
*
* @param string $username the username
* @param string $repository the repository
* @param int $id the issue number
*
* @return array information about the issue
*/
public function show($username, $repository, $id)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id));
}
/**
* Create a new issue for the given username and repo.
* The issue is assigned to the authenticated user. Requires authentication.
*
* @link http://developer.github.com/v3/issues/
*
* @param string $username the username
* @param string $repository the repository
* @param array $params the new issue data
*
* @throws MissingArgumentException
*
* @return array information about the issue
*/
public function create($username, $repository, array $params)
{
if (!isset($params['title'])) {
throw new MissingArgumentException(['title']);
}
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues', $params);
}
/**
* Update issue information's by username, repo and issue number. Requires authentication.
*
* @link http://developer.github.com/v3/issues/
*
* @param string $username the username
* @param string $repository the repository
* @param int $id the issue number
* @param array $params key=>value user attributes to update.
* key can be title or body
*
* @return array information about the issue
*/
public function update($username, $repository, $id, array $params)
{
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id), $params);
}
/**
* Lock an issue. Users with push access can lock an issue's conversation.
*
* @link https://developer.github.com/v3/issues/#lock-an-issue
*
* @param string $username
* @param string $repository
* @param int $id
*
* @return string
*/
public function lock($username, $repository, $id)
{
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id).'/lock');
}
/**
* Unlock an issue. Users with push access can unlock an issue's conversation.
*
* @link https://developer.github.com/v3/issues/#lock-an-issue
*
* @param string $username
* @param string $repository
* @param int $id
*
* @return string
*/
public function unlock($username, $repository, $id)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id).'/lock');
}
/**
* List an issue comments.
*
* @link http://developer.github.com/v3/issues/comments/
*
* @return Comments
*/
public function comments()
{
return new Comments($this->client);
}
/**
* List all project events.
*
* @link http://developer.github.com/v3/issues/events/
*
* @return Events
*/
public function events()
{
return new Events($this->client);
}
/**
* List all project labels.
*
* @link http://developer.github.com/v3/issues/labels/
*
* @return Labels
*/
public function labels()
{
return new Labels($this->client);
}
/**
* List all project milestones.
*
* @link http://developer.github.com/v3/issues/milestones/
*
* @return Milestones
*/
public function milestones()
{
return new Milestones($this->client);
}
/**
* List all assignees.
*
* @link https://developer.github.com/v3/issues/assignees/
*
* @return Assignees
*/
public function assignees()
{
return new Assignees($this->client);
}
/**
* List all events.
*
* @link https://developer.github.com/v3/issues/timeline/
*
* @return Timeline
*/
public function timeline()
{
return new Timeline($this->client);
}
}