Skip to content

Commit c5475e2

Browse files
committed
Merge pull request KnpLabs#136 from syphernl/patch-1
Allow to provide parameters for PullRequests list
2 parents 3b2ac45 + d84b9ff commit c5475e2

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

lib/Github/Api/PullRequest.php

100644100755
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@ class PullRequest extends AbstractApi
1919
*
2020
* @param string $username the username
2121
* @param string $repository the repository
22-
* @param string $state the state of the fetched pull requests.
23-
* The API seems to automatically default to 'open'
24-
* @param integer $page the page
25-
* @param integer $perPage the per page
22+
* @param array $params a list of extra parameters.
2623
*
2724
* @return array array of pull requests for the project
2825
*/
29-
public function all($username, $repository, $state = null, $page = 1, $perPage = 30)
26+
public function all($username, $repository, array $params = array())
3027
{
31-
$parameters = array(
32-
'page' => $page,
33-
'per_page' => $perPage,
34-
'state' => $state,
35-
);
28+
$parameters = array_merge(array(
29+
'page' => 1,
30+
'per_page' => 30
31+
), $params);
3632

3733
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls', $parameters);
3834
}

test/Github/Tests/Api/PullRequestTest.php

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function shouldGetOpenPullRequests()
3333
->with('repos/ezsystems/ezpublish/pulls', array('state' => 'open', 'per_page' => 30, 'page' => 1))
3434
->will($this->returnValue($expectedArray));
3535

36-
$this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', 'open'));
36+
$this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', array('state' => 'open')));
3737
}
3838

3939
/**
@@ -49,7 +49,7 @@ public function shouldGetClosedPullRequests()
4949
->with('repos/ezsystems/ezpublish/pulls', array('state' => 'closed', 'per_page' => 30, 'page' => 1))
5050
->will($this->returnValue($expectedArray));
5151

52-
$this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', 'closed'));
52+
$this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', array('state' => 'closed')));
5353
}
5454

5555
/**

0 commit comments

Comments
 (0)