Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions lib/Github/Api/PullRequest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ class PullRequest extends AbstractApi
*
* @param string $username the username
* @param string $repository the repository
* @param string $state the state of the fetched pull requests.
* The API seems to automatically default to 'open'
* @param integer $page the page
* @param integer $perPage the per page
* @param array $params a list of extra parameters.
*
* @return array array of pull requests for the project
*/
public function all($username, $repository, $state = null, $page = 1, $perPage = 30)
public function all($username, $repository, array $params = array())
{
$parameters = array(
'page' => $page,
'per_page' => $perPage,
'state' => $state,
);
$parameters = array_merge(array(
'page' => 1,
'per_page' => 30
), $params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add $defaults array containing basic values from constructor and merge it

<?php

$parameters = array_merge(array(
    'page' => 1,
    'per_page' => 30
), $params);


return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls', $parameters);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 1 blank line before return statement

}
Expand Down
4 changes: 2 additions & 2 deletions test/Github/Tests/Api/PullRequestTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function shouldGetOpenPullRequests()
->with('repos/ezsystems/ezpublish/pulls', array('state' => 'open', 'per_page' => 30, 'page' => 1))
->will($this->returnValue($expectedArray));

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

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

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

/**
Expand Down