1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Manavo\DoneDone; |
4
|
|
|
|
5
|
|
|
class Project |
6
|
|
|
{ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @var Client |
10
|
|
|
*/ |
11
|
|
|
private $client; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @var int |
15
|
|
|
*/ |
16
|
|
|
private $id; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param Client $client |
20
|
|
|
* @param int $id |
21
|
|
|
*/ |
22
|
6 |
|
function __construct($client, $id) |
|
|
|
|
23
|
|
|
{ |
24
|
6 |
|
$this->client = $client; |
25
|
6 |
|
$this->id = $id; |
26
|
6 |
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Get all the people associated with this project |
30
|
|
|
* |
31
|
|
|
* @return array |
32
|
|
|
*/ |
33
|
|
|
public function people() |
34
|
|
|
{ |
35
|
|
|
return $this->client->get('projects/' . $this->id . '/people'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Get all the issues associated with this project |
40
|
|
|
* |
41
|
|
|
* @return array |
42
|
|
|
*/ |
43
|
|
|
public function issues() |
44
|
|
|
{ |
45
|
|
|
return $this->client->get('projects/' . $this->id . '/issues/all'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param int $id |
50
|
|
|
* |
51
|
|
|
* @return Issue |
52
|
|
|
*/ |
53
|
3 |
|
public function issue($id) |
54
|
|
|
{ |
55
|
3 |
|
return new Issue($this->client, $this->id, $id); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Get all the active issues associated with this project |
60
|
|
|
* |
61
|
|
|
* @return array |
62
|
|
|
*/ |
63
|
|
|
public function activeIssues() |
64
|
|
|
{ |
65
|
|
|
return $this->client->get( |
66
|
|
|
'projects/' . $this->id . '/issues/all_active' |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Get all the closed and fixed issues associated with this project |
72
|
|
|
* |
73
|
|
|
* @return array |
74
|
|
|
*/ |
75
|
|
|
public function closedAndFixedIssues() |
76
|
|
|
{ |
77
|
|
|
return $this->client->get( |
78
|
|
|
'projects/' . $this->id . '/issues/all_closed_and_fixed' |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Get all the issues by a filter associated with this project |
84
|
|
|
* |
85
|
|
|
* @param int $filter |
86
|
|
|
* |
87
|
|
|
* @return array |
88
|
|
|
*/ |
89
|
|
|
public function issuesByFilter($filter) |
90
|
|
|
{ |
91
|
|
|
return $this->client->get( |
92
|
|
|
sprintf( |
93
|
|
|
'projects/%d/issues/by_custom_filter/%d', |
94
|
|
|
$this->id, |
95
|
|
|
$filter |
96
|
|
|
) |
97
|
|
|
); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Get all the issues which are waiting on you, and are associated with |
102
|
|
|
* this project |
103
|
|
|
* |
104
|
|
|
* @return array |
105
|
|
|
*/ |
106
|
|
|
public function issuesWaitingOnYou() |
107
|
|
|
{ |
108
|
|
|
return $this->client->get( |
109
|
|
|
sprintf('projects/%d/issues/waiting_on_you', $this->id) |
110
|
|
|
); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Get all the issues which are waiting on them |
115
|
|
|
* |
116
|
|
|
* @return array |
117
|
|
|
*/ |
118
|
|
|
public function issuesWaitingOnThem() |
119
|
|
|
{ |
120
|
|
|
return $this->client->get( |
121
|
|
|
sprintf('projects/%d/issues/waiting_on_them', $this->id) |
122
|
|
|
); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Get release builds of this project |
127
|
|
|
* |
128
|
|
|
* @return array |
129
|
|
|
*/ |
130
|
|
|
public function releaseBuilds() |
131
|
|
|
{ |
132
|
|
|
return $this->client->get('projects/' . $this->id . '/release_builds'); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Get release builds of this project |
137
|
|
|
* |
138
|
|
|
* @return ReleaseBuildInfo |
139
|
|
|
*/ |
140
|
|
|
public function releaseBuildInfo() |
141
|
|
|
{ |
142
|
|
|
return new ReleaseBuildInfo($this->client->get('projects/' . $this->id . '/release_builds/info')); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Get filters of this project |
147
|
|
|
* |
148
|
|
|
* @return array |
149
|
|
|
*/ |
150
|
|
|
public function filters() |
151
|
|
|
{ |
152
|
|
|
return $this->client->get('projects/' . $this->id . '/custom_filters'); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Add a new issue to the project |
157
|
|
|
* |
158
|
|
|
* @param Issue $issue |
159
|
|
|
* |
160
|
|
|
* @return array |
161
|
|
|
*/ |
162
|
|
|
public function addIssue($issue) |
163
|
|
|
{ |
164
|
|
|
return $this->client->post( |
165
|
|
|
'projects/' . $this->id . '/issues', $issue->toArray() |
166
|
|
|
); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Create a new release build for the project |
171
|
|
|
* |
172
|
|
|
* @param ReleaseBuild $releaseBuild |
173
|
|
|
* |
174
|
|
|
* @return array |
175
|
|
|
*/ |
176
|
|
|
public function createReleaseBuild($releaseBuild) |
177
|
|
|
{ |
178
|
|
|
return $this->client->post( |
179
|
|
|
sprintf('projects/%d/release_builds', $this->id), |
180
|
|
|
$releaseBuild->toArray() |
181
|
|
|
); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
} |
185
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.