Skip to content

Commit

Permalink
Set new parameters as null instead of default values
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrimaud committed Apr 20, 2020
1 parent 6aa74fb commit 041af92
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/Github/Api/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Notification extends AbstractApi
* @param bool $includingRead
* @param bool $participating
* @param DateTime|null $since
* @param DateTime|null $before
*
* @return array array of notifications
*/
Expand Down
18 changes: 13 additions & 5 deletions lib/Github/Api/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,22 @@ public function update($organization, array $params)
*
* @return array the repositories
*/
public function repositories($organization, $type = 'all', $page = 1, $sort = 'created', $direction = 'desc')
public function repositories($organization, $type = 'all', $page = 1, $sort = null, $direction = null)
{
return $this->get('/orgs/'.rawurlencode($organization).'/repos', [
$parameters = [
'type' => $type,
'page' => $page,
'sort' => $sort,
'direction' => $direction,
]);
];

if($sort !== null){
$parameters['sort'] = $sort;
}

if($direction !== null){
$parameters['direction'] = $direction;
}

return $this->get('/orgs/'.rawurlencode($organization).'/repos', $parameters);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/Github/Tests/Api/OrganizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function shouldGetOrganizationRepositories()
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/orgs/KnpLabs/repos', ['type' => 'all', 'page' => 1, 'sort' => 'created', 'direction' => 'desc'])
->with('/orgs/KnpLabs/repos', ['type' => 'all', 'page' => 1])
->will($this->returnValue($expectedArray));

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

0 comments on commit 041af92

Please sign in to comment.