Skip to content

Commit 4b680e8

Browse files
committed
Merge pull request #121 from seanhellwig/users/userid/starred
Update User API to include /users/:user/starred
2 parents df51b8f + 57e674c commit 4b680e8

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

doc/users.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ Returns an array of followed users.
9797
$users = $client->api('user')->watched('ornicar');
9898
```
9999

100+
### Get repos that a specific user has starred
101+
102+
```php
103+
$users = $client->api('user')->starred('ornicar');
104+
```
105+
100106
For authenticated user use.
101107

102108
> Requires [authentication](security.md).

lib/Github/Api/User.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ public function watched($username)
7272
return $this->get('users/'.rawurlencode($username).'/watched');
7373
}
7474

75+
/**
76+
* Request starred repositories that a specific user has starred
77+
* @link http://developer.github.com/v3/activity/starring/
78+
*
79+
* @param string $username the username
80+
* @param int $page the page number of the paginated result set
81+
* @return array list of starred repositories
82+
*/
83+
public function starred($username, $page = 1)
84+
{
85+
return $this->get('users/'.rawurlencode($username).'/starred', array(
86+
'page' => $page
87+
));
88+
}
89+
7590
/**
7691
* Request the repository that a specific user is watching
7792
* @link http://developer.github.com/v3/activity/watching/

test/Github/Tests/Functional/UserTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,30 @@ public function shouldGetReposBeingWatched()
110110
$this->assertArrayHasKey('git_url', $repo);
111111
$this->assertArrayHasKey('svn_url', $repo);
112112
}
113+
114+
/**
115+
* @test
116+
*/
117+
public function shouldGetReposBeingStarred()
118+
{
119+
$username = 'l3l0';
120+
121+
$repos = $this->client->api('user')->starred($username);
122+
$repo = array_pop($repos);
123+
124+
$this->assertArrayHasKey('id', $repo);
125+
$this->assertArrayHasKey('name', $repo);
126+
$this->assertArrayHasKey('description', $repo);
127+
$this->assertArrayHasKey('url', $repo);
128+
$this->assertArrayHasKey('has_wiki', $repo);
129+
$this->assertArrayHasKey('has_issues', $repo);
130+
$this->assertArrayHasKey('forks', $repo);
131+
$this->assertArrayHasKey('updated_at', $repo);
132+
$this->assertArrayHasKey('created_at', $repo);
133+
$this->assertArrayHasKey('pushed_at', $repo);
134+
$this->assertArrayHasKey('open_issues', $repo);
135+
$this->assertArrayHasKey('ssh_url', $repo);
136+
$this->assertArrayHasKey('git_url', $repo);
137+
$this->assertArrayHasKey('svn_url', $repo);
138+
}
113139
}

0 commit comments

Comments
 (0)