-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGithubIssueMilestones.php
83 lines (73 loc) · 2.19 KB
/
GithubIssueMilestones.php
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
<?php
require_once('Github.php');
class GithubIssueMilestones extends Github {
const STATE_OPEN = 'open';
const STATE_CLOSED = 'closed';
/**
* List milestones for a repository
*
* @param string $username
* @param string $repository
*/
public function listRepository($username, $repository) {
return $this->request('/repos/'.$username.'/'.$repository.'/milestones');
}
/**
* Get a single milestone
*
* @param string $username
* @param string $repository
* @param int $number
*/
public function get($username, $repository, $number) {
return $this->request('/repos/'.$username.'/'.$repository.'/milestones/'.$number);
}
/**
* Create a milestone
*
* @param string $username
* @param string $repository
* @param string $title
* @param string $state (GithubIssueMilestones::STATE_OPEN, GithubIssueMilestones::STATE_CLOSED)
* @param string $description
* @param date $due_on
*/
public function create($username, $repository, $title, $state = false, $description = false, $due_on = false) {
return $this->request('/repos/'.$username.'/'.$repository.'/milestones', 'POST', array(
'title' => $title,
'state' => $state,
'description' => $description,
'due_on' => date('c', strtotime($due_on)),
));
}
/**
* Update a milestone
*
* @param string $username
* @param string $repository
* @param int $number
* @param string $title
* @param string $state (GithubIssueMilestones::STATE_OPEN, GithubIssueMilestones::STATE_CLOSED)
* @param string $description
* @param date $due_on
*/
public function edit($username, $repository, $number, $title, $state = false, $description = false, $due_on = false) {
return $this->request('/repos/'.$username.'/'.$repository.'/milestones/'.$number, 'PATCH', array(
'title' => $title,
'state' => $state,
'description' => $description,
'due_on' => date('c', strtotime($due_on)),
));
}
/**
* Delete a milestone
*
* @param string $username
* @param string $repository
* @param int $number
*/
public function delete($username, $repository, $number) {
return ($this->request('/repos/'.$username.'/'.$repository.'/milestones/'.$number, 'DELETE', array(), true) == 204) ? true : false;
}
}
?>