Skip to content

Commit db8ec7a

Browse files
committed
Added missing sort options on user repositories fetch
Fixed cs
1 parent ac28d13 commit db8ec7a

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

lib/Github/Api/CurrentUser.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,19 @@ public function organizations()
8989
/**
9090
* @link http://developer.github.com/v3/repos/#list-your-repositories
9191
*
92+
* @param string $type role in the repository
93+
* @param string $sort sort by
94+
* @param string $direction direction of sort, ask or desc
95+
9296
* @return array
9397
*/
94-
public function repositories()
98+
public function repositories($type = 'owner', $sort = 'full_name', $direction = 'asc')
9599
{
96-
return $this->get('user/repos');
100+
return $this->get('user/repos', array(
101+
$type,
102+
$sort,
103+
$direction
104+
));
97105
}
98106

99107
/**

lib/Github/Api/User.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,19 @@ public function subscriptions($username)
118118
* Get the repositories of a user
119119
* @link http://developer.github.com/v3/repos/
120120
*
121-
* @param string $username the username
122-
* @return array list of the user repositories
121+
* @param string $username the username
122+
* @param string $type role in the repository
123+
* @param string $sort sort by
124+
* @param string $direction direction of sort, ask or desc
125+
* @return array list of the user repositories
123126
*/
124-
public function repositories($username)
127+
public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc')
125128
{
126-
return $this->get('users/'.rawurlencode($username).'/repos');
129+
return $this->get('users/'.rawurlencode($username).'/repos', array(
130+
$type,
131+
$sort,
132+
$direction
133+
));
127134
}
128135

129136
/**

test/Github/Tests/Api/UserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function shouldGetUserRepositories()
116116
$api = $this->getApiMock();
117117
$api->expects($this->once())
118118
->method('get')
119-
->with('users/l3l0/repos')
119+
->with('users/l3l0/repos', array('owner', 'full_name', 'asc'))
120120
->will($this->returnValue($expectedArray));
121121

122122
$this->assertEquals($expectedArray, $api->repositories('l3l0'));

0 commit comments

Comments
 (0)