From db8ec7a4c9e49568c8cf8b15738701cdb06e959f Mon Sep 17 00:00:00 2001 From: "Nek (Maxime Veber)" Date: Thu, 19 Jun 2014 17:56:17 +0200 Subject: [PATCH] Added missing sort options on user repositories fetch Fixed cs --- lib/Github/Api/CurrentUser.php | 12 ++++++++++-- lib/Github/Api/User.php | 15 +++++++++++---- test/Github/Tests/Api/UserTest.php | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/Github/Api/CurrentUser.php b/lib/Github/Api/CurrentUser.php index 7b1af4381c8..38318959589 100644 --- a/lib/Github/Api/CurrentUser.php +++ b/lib/Github/Api/CurrentUser.php @@ -89,11 +89,19 @@ public function organizations() /** * @link http://developer.github.com/v3/repos/#list-your-repositories * + * @param string $type role in the repository + * @param string $sort sort by + * @param string $direction direction of sort, ask or desc + * @return array */ - public function repositories() + public function repositories($type = 'owner', $sort = 'full_name', $direction = 'asc') { - return $this->get('user/repos'); + return $this->get('user/repos', array( + $type, + $sort, + $direction + )); } /** diff --git a/lib/Github/Api/User.php b/lib/Github/Api/User.php index 7573c6e2b98..f30659c2b2d 100644 --- a/lib/Github/Api/User.php +++ b/lib/Github/Api/User.php @@ -118,12 +118,19 @@ public function subscriptions($username) * Get the repositories of a user * @link http://developer.github.com/v3/repos/ * - * @param string $username the username - * @return array list of the user repositories + * @param string $username the username + * @param string $type role in the repository + * @param string $sort sort by + * @param string $direction direction of sort, ask or desc + * @return array list of the user repositories */ - public function repositories($username) + public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc') { - return $this->get('users/'.rawurlencode($username).'/repos'); + return $this->get('users/'.rawurlencode($username).'/repos', array( + $type, + $sort, + $direction + )); } /** diff --git a/test/Github/Tests/Api/UserTest.php b/test/Github/Tests/Api/UserTest.php index 05eb7061b0d..fab2969269d 100644 --- a/test/Github/Tests/Api/UserTest.php +++ b/test/Github/Tests/Api/UserTest.php @@ -116,7 +116,7 @@ public function shouldGetUserRepositories() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('users/l3l0/repos') + ->with('users/l3l0/repos', array('owner', 'full_name', 'asc')) ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->repositories('l3l0'));