@@ -23,13 +23,7 @@ class Repo extends Api
23
23
*/
24
24
public function search ($ query , $ language = '' , $ startPage = 1 )
25
25
{
26
- //todo old api
27
- $ response = $ this ->get ('repos/search/ ' .urlencode ($ query ), array (
28
- 'language ' => strtolower ($ language ),
29
- 'start_page ' => $ startPage
30
- ));
31
-
32
- return $ response ['repositories ' ];
26
+ throw new \BadMethodCallException ('Method cannot be implemented using new api version ' );
33
27
}
34
28
35
29
/**
@@ -44,7 +38,7 @@ public function getPushableRepos()
44
38
45
39
/**
46
40
* Get the repositories of a user
47
- * http://develop .i.8713187.xyz/p/repo.html
41
+ * @link http://developer .i.8713187.xyz/v3/repos/
48
42
*
49
43
* @param string $username the username
50
44
* @return array list of the user repos
@@ -56,6 +50,7 @@ public function getUserRepos($username)
56
50
57
51
/**
58
52
* Get extended information about a repository by its username and repo name
53
+ * @link http://developer.github.com/v3/repos/
59
54
*
60
55
* @param string $username the user who owns the repo
61
56
* @param string $repo the name of the repo
@@ -67,7 +62,8 @@ public function show($username, $repo)
67
62
}
68
63
69
64
/**
70
- * create repo
65
+ * Create repo
66
+ * @link http://developer.github.com/v3/repos/
71
67
*
72
68
* @param string $name name of the repository
73
69
* @param string $description repo description
@@ -86,7 +82,7 @@ public function create($name, $description = '', $homepage = '', $public = true)
86
82
}
87
83
88
84
/**
89
- * delete repo
85
+ * Delete repo
90
86
*
91
87
* @param string $name name of the repository
92
88
* @param string $token delete token
@@ -116,6 +112,7 @@ public function delete($name, $token = null, $force = false)
116
112
117
113
/**
118
114
* Set information of a repository
115
+ * @link http://developer.github.com/v3/repos/
119
116
*
120
117
* @param string $username the user who owns the repo
121
118
* @param string $repo the name of the repo
@@ -128,7 +125,8 @@ public function setRepoInfo($username, $repo, $values)
128
125
}
129
126
130
127
/**
131
- * Set the visibility of a repostory to public
128
+ * Set the visibility of a repository to public
129
+ * @link http://developer.github.com/v3/repos/
132
130
*
133
131
* @param string $username the user who owns the repo
134
132
* @param string $repo the name of the repo
@@ -140,7 +138,8 @@ public function setPublic($username, $repo)
140
138
}
141
139
142
140
/**
143
- * Set the visibility of a repostory to private
141
+ * Set the visibility of a repository to private
142
+ * @link http://developer.github.com/v3/repos/
144
143
*
145
144
* @param string $username the user who owns the repo
146
145
* @param string $repo the name of the repo
@@ -153,6 +152,7 @@ public function setPrivate($username, $repo)
153
152
154
153
/**
155
154
* Get the list of deploy keys for a repository
155
+ * @link http://developer.github.com/v3/repos/keys/
156
156
*
157
157
* @param string $username the user who owns the repo
158
158
* @param string $repo the name of the repo
@@ -165,6 +165,7 @@ public function getDeployKeys($username, $repo)
165
165
166
166
/**
167
167
* Add a deploy key for a repository
168
+ * @link http://developer.github.com/v3/repos/keys/
168
169
*
169
170
* @param string $username the user who owns the repo
170
171
* @param string $repo the name of the repo
@@ -182,6 +183,7 @@ public function addDeployKey($username, $repo, $title, $key)
182
183
183
184
/**
184
185
* Delete a deploy key from a repository
186
+ * @link http://developer.github.com/v3/repos/keys/
185
187
*
186
188
* @param string $username the user who owns the repo
187
189
* @param string $repo the name of the repo
@@ -195,136 +197,135 @@ public function removeDeployKey($username, $repo, $id)
195
197
196
198
/**
197
199
* Get the collaborators of a repository
200
+ * @link http://developer.github.com/v3/repos/collaborators/
198
201
*
199
202
* @param string $username the user who owns the repo
200
203
* @param string $repo the name of the repo
201
204
* @return array list of the repo collaborators
202
205
*/
203
206
public function getRepoCollaborators ($ username , $ repo )
204
207
{
205
- $ response = $ this ->get ('repos/show/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/collaborators ' );
208
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/collaborators ' );
209
+ }
206
210
207
- return $ response ['collaborators ' ];
211
+ /**
212
+ * Get the collaborator of a repository
213
+ * @link http://developer.github.com/v3/repos/collaborators/
214
+ *
215
+ * @param string $username the user who owns the repo
216
+ * @param string $repo the name of the repo
217
+ * @param string $user the user which we seek
218
+ * @return array list of the repo collaborators
219
+ */
220
+ public function getRepoCollaborator ($ username , $ repo , $ user )
221
+ {
222
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/collaborators/ ' .urlencode ($ user ));
208
223
}
209
224
210
225
/**
211
226
* Add a collaborator to a repository
212
- * http://develop .i.8713187.xyz/p/repo.html
227
+ * @link http://developer .i.8713187.xyz/v3/repos/collaborators/
213
228
*
229
+ * @param string $username the user who owns the repo
214
230
* @param string $repo the name of the repo
215
- * @param string $username the user who should be added as a collaborator
231
+ * @param string $user the user who should be added as a collaborator
216
232
* @return array list of the repo collaborators
217
233
*/
218
- public function addRepoCollaborator ($ repo , $ username )
234
+ public function addRepoCollaborator ($ username , $ repo , $ user )
219
235
{
220
- $ response = $ this ->post ('repos/collaborators/ ' .urlencode ($ repo ).'/add/ ' .urlencode ($ username ));
221
-
222
- return $ response ['collaborators ' ];
236
+ return $ this ->put ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/collaborators/ ' .urlencode ($ user ));
223
237
}
224
238
225
239
/**
226
240
* Delete a collaborator from a repository
227
- * http://develop .i.8713187.xyz/p/repo.html
241
+ * @link http://developer .i.8713187.xyz/v3/repos/collaborators/
228
242
*
243
+ * @param string $username the user who owns the repo
229
244
* @param string $repo the name of the repo
230
- * @param string $username the user who should be removed as a collaborator
245
+ * @param string $user the user who should be removed as a collaborator
231
246
* @return array list of the repo collaborators
232
247
*/
233
- public function removeRepoCollaborator ($ repo , $ username )
248
+ public function removeRepoCollaborator ($ repo , $ username, $ user )
234
249
{
235
- $ response = $ this ->post ('repos/collaborators/ ' .urlencode ($ repo ).'/remove/ ' .urlencode ($ username ));
236
-
237
- return $ response ['collaborators ' ];
250
+ return $ this ->delete ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/collaborators/ ' .urlencode ($ user ));
238
251
}
239
252
240
253
/**
241
254
* Make the authenticated user watch a repository
242
- * http://develop .i.8713187.xyz/p/repo.html
255
+ * @link http://developer .i.8713187.xyz/v3/repos/watching/
243
256
*
244
257
* @param string $username the user who owns the repo
245
258
* @param string $repo the name of the repo
246
259
* @return array informations about the repo
247
260
*/
248
261
public function watch ($ username , $ repo )
249
262
{
250
- $ response = $ this ->get ('repos/watch/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ));
251
-
252
- return $ response ['repository ' ];
263
+ return $ this ->put ('user/watched/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ));
253
264
}
254
265
255
266
/**
256
267
* Make the authenticated user unwatch a repository
257
- * http://develop .i.8713187.xyz/p/repo.html
268
+ * @link http://developer .i.8713187.xyz/v3/repos/watching/
258
269
*
259
270
* @param string $username the user who owns the repo
260
271
* @param string $repo the name of the repo
261
272
* @return array informations about the repo
262
273
*/
263
274
public function unwatch ($ username , $ repo )
264
275
{
265
- $ response = $ this ->get ('repos/unwatch/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ));
266
-
267
- return $ response ['repository ' ];
276
+ return $ this ->delete ('user/watched/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ));
268
277
}
269
278
270
279
/**
271
280
* Make the authenticated user fork a repository
272
- * http://develop .i.8713187.xyz/p/repo.html
281
+ * @link http://developer .i.8713187.xyz/v3/repos/forks/
273
282
*
274
283
* @param string $username the user who owns the repo
275
284
* @param string $repo the name of the repo
276
285
* @return array informations about the newly forked repo
277
286
*/
278
287
public function fork ($ username , $ repo )
279
288
{
280
- $ response = $ this ->get ('repos/fork/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ));
281
-
282
- return $ response ['repository ' ];
289
+ return $ this ->post ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/forks ' );
283
290
}
284
291
285
292
/**
286
293
* Get the tags of a repository
287
- * http://develop .i.8713187.xyz/p/repo.html
294
+ * @link http://developer .i.8713187.xyz/v3/repos/
288
295
*
289
296
* @param string $username the user who owns the repo
290
297
* @param string $repo the name of the repo
291
298
* @return array list of the repo tags
292
299
*/
293
300
public function getRepoTags ($ username , $ repo )
294
301
{
295
- $ response = $ this ->get ('repos/show/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/tags ' );
296
-
297
- return $ response ['tags ' ];
302
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/tags ' );
298
303
}
299
304
300
305
/**
301
306
* Get the branches of a repository
302
- * http://develop .i.8713187.xyz/p/repo.html
307
+ * @link http://developer .i.8713187.xyz/v3/repos/
303
308
*
304
309
* @param string $username the username
305
310
* @param string $repo the name of the repo
306
311
* @return array list of the repo branches
307
312
*/
308
313
public function getRepoBranches ($ username , $ repo )
309
314
{
310
- $ response = $ this ->get ('repos/show/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/branches ' );
311
-
312
- return $ response ['branches ' ];
315
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/branches ' );
313
316
}
314
317
315
318
/**
316
319
* Get the watchers of a repository
317
- * http://develop .i.8713187.xyz/p/repo.html
320
+ * @link http://developer .i.8713187.xyz/v3/repos/watching/
318
321
*
319
322
* @param string $username the user who owns the repo
320
323
* @param string $repo the name of the repo
321
324
* @return array list of the repo watchers
322
325
*/
323
326
public function getRepoWatchers ($ username , $ repo )
324
327
{
325
- $ response = $ this ->get ('repos/show/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/watchers ' );
326
-
327
- return $ response ['watchers ' ];
328
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/watchers ' );
328
329
}
329
330
330
331
/**
@@ -337,44 +338,51 @@ public function getRepoWatchers($username, $repo)
337
338
*/
338
339
public function getRepoNetwork ($ username , $ repo )
339
340
{
340
- $ response = $ this ->get ('repos/show/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/network ' );
341
-
342
- return $ response ['network ' ];
341
+ throw new \BadMethodCallException ('Method cannot be implemented using new api version ' );
343
342
}
344
343
345
344
/**
346
345
* Get the language breakdown of a repository
347
- * http://develop .i.8713187.xyz/p/repo.html
346
+ * @link http://developer .i.8713187.xyz/v3/repos/
348
347
*
349
348
* @param string $username the user who owns the repo
350
349
* @param string $repo the name of the repo
351
350
* @return array list of the languages
352
351
*/
353
352
public function getRepoLanguages ($ username , $ repo )
354
353
{
355
- $ response = $ this ->get ('repos/show/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/languages ' );
356
-
357
- return $ response ['languages ' ];
354
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/languages ' );
358
355
}
359
356
360
357
/**
361
358
* Get the contributors of a repository
362
- * http://develop .i.8713187.xyz/p/repo.html
359
+ * @link http://developer .i.8713187.xyz/v3/repos/
363
360
*
364
361
* @param string $username the user who owns the repo
365
362
* @param string $repo the name of the repo
366
- * @param boolean $includingNonGithubUsers by default, the list only shows GitHub users. You can include non-users too by setting this to true
363
+ * @param boolean $includingAnonymous by default, the list only shows GitHub users. You can include non-users too by setting this to true
367
364
* @return array list of the repo contributors
368
365
*/
369
- public function getRepoContributors ($ username , $ repo , $ includingNonGithubUsers = false )
366
+ public function getRepoContributors ($ username , $ repo , $ includingAnonymous = false )
370
367
{
371
368
$ url = 'repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/contributors ' ;
372
- if ($ includingNonGithubUsers ) {
369
+ if ($ includingAnonymous ) {
373
370
$ url .= '?anon=1 ' ;
374
371
}
375
- $ response = $ this ->get ($ url );
376
372
377
- return $ response ;
373
+ return $ this -> get ( $ url ) ;
378
374
}
379
375
376
+ /**
377
+ * Get the teams of a repository
378
+ * @link http://developer.github.com/v3/repos/
379
+ *
380
+ * @param string $username the user who owns the repo
381
+ * @param string $repo the name of the repo
382
+ * @return array list of the languages
383
+ */
384
+ public function getRepoTeams ($ username , $ repo )
385
+ {
386
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/teams ' );
387
+ }
380
388
}
0 commit comments