Skip to content

Commit fb54d8a

Browse files
committed
added starring api
1 parent e67a83e commit fb54d8a

File tree

2 files changed

+70
-6
lines changed

2 files changed

+70
-6
lines changed

lib/Github/Api/CurrentUser.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Github\Api\CurrentUser\Followers;
88
use Github\Api\CurrentUser\Notifications;
99
use Github\Api\CurrentUser\Watchers;
10+
use Github\Api\CurrentUser\Starred;
1011

1112
/**
1213
* @link http://developer.github.com/v3/users/
@@ -119,13 +120,11 @@ public function watched($page = 1)
119120
));
120121
}
121122

122-
/**
123-
* @link http://developer.github.com/changes/2012-9-5-watcher-api/
123+
/**
124+
* @return Starred
124125
*/
125-
public function starred($page = 1)
126+
public function starred()
126127
{
127-
return $this->get('user/starred', array(
128-
'page' => $page
129-
));
128+
return new Starred($this->client);
130129
}
131130
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace Github\Api\CurrentUser;
4+
5+
use Github\Api\AbstractApi;
6+
7+
/**
8+
* @link https://developer.github.com/v3/activity/starring/
9+
* @author Felipe Valtl de Mello <[email protected]>
10+
*/
11+
class Starred extends AbstractApi
12+
{
13+
/**
14+
* List repositories starred by the authenticated user
15+
* @link https://developer.github.com/v3/activity/starring/
16+
*
17+
* @param integer $page
18+
* @return array
19+
*/
20+
public function all($page = 1)
21+
{
22+
return $this->get('user/starred', array(
23+
'page' => $page
24+
));
25+
}
26+
27+
/**
28+
* Check that the authenticated user starres a repository
29+
* @link https://developer.github.com/v3/activity/starring/
30+
*
31+
* @param string $username the user who owns the repo
32+
* @param string $repository the name of the repo
33+
* @return array
34+
*/
35+
public function check($username, $repository)
36+
{
37+
return $this->get('user/starred/'.rawurlencode($username).'/'.rawurlencode($repository));
38+
}
39+
40+
/**
41+
* Make the authenticated user star a repository
42+
* @link https://developer.github.com/v3/activity/starring/
43+
*
44+
* @param string $username the user who owns the repo
45+
* @param string $repository the name of the repo
46+
* @return array
47+
*/
48+
public function star($username, $repository)
49+
{
50+
return $this->put('user/starred/'.rawurlencode($username).'/'.rawurlencode($repository));
51+
}
52+
53+
/**
54+
* Make the authenticated user unstar a repository
55+
* @link https://developer.github.com/v3/activity/starring
56+
*
57+
* @param string $username the user who owns the repo
58+
* @param string $repository the name of the repo
59+
* @return array
60+
*/
61+
public function unstar($username, $repository)
62+
{
63+
return $this->delete('user/starred/'.rawurlencode($username).'/'.rawurlencode($repository));
64+
}
65+
}

0 commit comments

Comments
 (0)