Repository navigation
Expand file tree
/
Copy pathGitHubIssues.php
More file actions
142 lines (120 loc) · 3.89 KB
/
Copy pathGitHubIssues.php
File metadata and controls
142 lines (120 loc) · 3.89 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
<?php
require_once(__DIR__ . '/../GitHubClient.php');
require_once(__DIR__ . '/../GitHubService.php');
require_once(__DIR__ . '/GitHubIssuesAssignees.php');
require_once(__DIR__ . '/GitHubIssuesComments.php');
require_once(__DIR__ . '/GitHubIssuesEvents.php');
require_once(__DIR__ . '/GitHubIssuesLabels.php');
require_once(__DIR__ . '/GitHubIssuesMilestones.php');
require_once(__DIR__ . '/../objects/GitHubIssue.php');
class GitHubIssues extends GitHubService
{
/**
* @var GitHubIssuesAssignees
*/
public $assignees;
/**
* @var GitHubIssuesComments
*/
public $comments;
/**
* @var GitHubIssuesEvents
*/
public $events;
/**
* @var GitHubIssuesLabels
*/
public $labels;
/**
* @var GitHubIssuesMilestones
*/
public $milestones;
/**
* Initialize sub services
*/
public function __construct(GitHubClient $client)
{
parent::__construct($client);
$this->assignees = new GitHubIssuesAssignees($client);
$this->comments = new GitHubIssuesComments($client);
$this->events = new GitHubIssuesEvents($client);
$this->labels = new GitHubIssuesLabels($client);
$this->milestones = new GitHubIssuesMilestones($client);
}
/**
* List issues
*
* @return GitHubIssue
*/
public function listIssues($owner, $repo)
{
$data = array();
return $this->client->request("/repos/$owner/$repo/issues", 'GET', $data, 200, 'GitHubIssue', true);
}
/**
* List issues
*
* @return GitHubIssue
*/
public function getIssue($owner, $repo, $number)
{
$data = array();
return $this->client->request("/repos/$owner/$repo/issues/$number", 'GET', $data, 200, 'GitHubIssue');
}
/**
* Create an issue
*
* @param $title string (Required) - The title of the issue.
* @param $body string (Optional) - The contents of the issue.
* @param $assignee string (Optional) - Login for the user that this issue should be assigned to.
* @param $milestone number (Optional) - Milestone to associate this issue with.
* @param $labels array (Optional) of strings - Labels to associate with this issue.
* Pass one or more Labels to _replace_ the set of Labels on this Issue.
* Send an empty array (`[]`) to clear all Labels from the Issue.
* @return GitHubIssue
*/
public function createAnIssue($owner, $repo, $title, $body = null, $assignee = null, $milestone = null, $labels = null)
{
$data = array();
$data['title'] = $title;
if(!is_null($body))
$data['body'] = $body;
if(!is_null($assignee))
$data['assignee'] = $assignee;
if(!is_null($milestone))
$data['milestone'] = $milestone;
if(!is_null($labels))
$data['labels'] = $labels;
$data = json_encode($data);
return $this->client->request("/repos/$owner/$repo/issues", 'POST', $data, 201, 'GitHubIssue');
}
/**
* Edit an issue
*
* @param $body string (Optional) - The contents of the issue.
* @param $assignee string (Optional) - Login for the user that this issue should be
* assigned to.
* @param $state string (Optional) - State of the issue: `open` or `closed`.
* @param $milestone number (Optional) - Milestone to associate this issue with.
* @param $labels array (Optional) of **strings** - Labels to associate with this
* issue. Pass one or more Labels to _replace_ the set of Labels on this
* Issue. Send an empty array (`[]`) to clear all Labels from the Issue.
* @return GitHubIssue
*/
public function editAnIssue($owner, $repo, $title, $number, $body = null, $assignee = null, $state = null, $milestone = null, $labels = null)
{
$data = array();
$data['title'] = $title;
if(!is_null($body))
$data['body'] = $body;
if(!is_null($assignee))
$data['assignee'] = $assignee;
if(!is_null($state))
$data['state'] = $state;
if(!is_null($milestone))
$data['milestone'] = $milestone;
if(!is_null($labels))
$data['labels'] = $labels;
return $this->client->request("/repos/$owner/$repo/issues/$number", 'PATCH', $data, 200, 'GitHubIssue');
}
}