Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ Returns an array of followed users.
$users = $client->api('user')->watched('ornicar');
```

### Get repos that a specific user has starred

```php
$users = $client->api('user')->starred('ornicar');
```

For authenticated user use.

> Requires [authentication](security.md).
Expand Down
15 changes: 15 additions & 0 deletions lib/Github/Api/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ public function watched($username)
return $this->get('users/'.rawurlencode($username).'/watched');
}

/**
* Request starred repositories that a specific user has starred
* @link http://developer.github.com/v3/activity/starring/
*
* @param string $username the username
* @param int $page the page number of the paginated result set
* @return array list of starred repositories
*/
public function starred($username, $page = 1)
{
return $this->get('users/'.rawurlencode($username).'/starred', array(
'page' => $page
));
}

/**
* Request the repository that a specific user is watching
* @link http://developer.github.com/v3/activity/watching/
Expand Down
26 changes: 26 additions & 0 deletions test/Github/Tests/Functional/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,30 @@ public function shouldGetReposBeingWatched()
$this->assertArrayHasKey('git_url', $repo);
$this->assertArrayHasKey('svn_url', $repo);
}

/**
* @test
*/
public function shouldGetReposBeingStarred()
{
$username = 'l3l0';

$repos = $this->client->api('user')->starred($username);
$repo = array_pop($repos);

$this->assertArrayHasKey('id', $repo);
$this->assertArrayHasKey('name', $repo);
$this->assertArrayHasKey('description', $repo);
$this->assertArrayHasKey('url', $repo);
$this->assertArrayHasKey('has_wiki', $repo);
$this->assertArrayHasKey('has_issues', $repo);
$this->assertArrayHasKey('forks', $repo);
$this->assertArrayHasKey('updated_at', $repo);
$this->assertArrayHasKey('created_at', $repo);
$this->assertArrayHasKey('pushed_at', $repo);
$this->assertArrayHasKey('open_issues', $repo);
$this->assertArrayHasKey('ssh_url', $repo);
$this->assertArrayHasKey('git_url', $repo);
$this->assertArrayHasKey('svn_url', $repo);
}
}