Skip to content

Commit b6f7f21

Browse files
committed
Merge pull request #141 from Nek-/feature/new-github-filter-options
Added missing sort options on user repositories fetch
2 parents 6ee8ad8 + db8ec7a commit b6f7f21

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
@@ -130,12 +130,19 @@ public function subscriptions($username)
130130
* Get the repositories of a user
131131
* @link http://developer.github.com/v3/repos/
132132
*
133-
* @param string $username the username
134-
* @return array list of the user repositories
133+
* @param string $username the username
134+
* @param string $type role in the repository
135+
* @param string $sort sort by
136+
* @param string $direction direction of sort, ask or desc
137+
* @return array list of the user repositories
135138
*/
136-
public function repositories($username)
139+
public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc')
137140
{
138-
return $this->get('users/'.rawurlencode($username).'/repos');
141+
return $this->get('users/'.rawurlencode($username).'/repos', array(
142+
$type,
143+
$sort,
144+
$direction
145+
));
139146
}
140147

141148
/**

test/Github/Tests/Api/UserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function shouldGetUserRepositories()
139139
$api = $this->getApiMock();
140140
$api->expects($this->once())
141141
->method('get')
142-
->with('users/l3l0/repos')
142+
->with('users/l3l0/repos', array('owner', 'full_name', 'asc'))
143143
->will($this->returnValue($expectedArray));
144144

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

0 commit comments

Comments
 (0)