Skip to content

Commit 5c3aee1

Browse files
author
Pierre Grimaud
committed
Add sort and direction for fetching organizations repos
1 parent 1cb5115 commit 5c3aee1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/Github/Api/Organization.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,18 @@ public function update($organization, array $params)
5353
* @param string $organization the user name
5454
* @param string $type the type of repositories
5555
* @param int $page the page
56+
* @param string $sort sort by
57+
* @param string $direction direction of sort, asc or desc
5658
*
5759
* @return array the repositories
5860
*/
59-
public function repositories($organization, $type = 'all', $page = 1)
61+
public function repositories($organization, $type = 'all', $page = 1, $sort = 'created', $direction = 'desc')
6062
{
6163
return $this->get('/orgs/'.rawurlencode($organization).'/repos', [
6264
'type' => $type,
6365
'page' => $page,
66+
'sort' => $sort,
67+
'direction' => $direction
6468
]);
6569
}
6670

test/Github/Tests/Api/OrganizationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function shouldGetOrganizationRepositories()
6262
$api = $this->getApiMock();
6363
$api->expects($this->once())
6464
->method('get')
65-
->with('/orgs/KnpLabs/repos', ['type' => 'all', 'page' => 1])
65+
->with('/orgs/KnpLabs/repos', ['type' => 'all', 'page' => 1, 'sort' => 'created', 'direction' => 'desc'])
6666
->will($this->returnValue($expectedArray));
6767

6868
$this->assertEquals($expectedArray, $api->repositories('KnpLabs'));

0 commit comments

Comments
 (0)