Skip to content

Commit 9bd650e

Browse files
Gummibeeracrobat
authored andcommitted
allow to set the requested page on all endpoints (#586)
* allow to set the requested page on all endpoints At the moment it's not possible to request another page on all endpoints (search for example). With this change the requested `page` can be set the same way like the `per_page`. * private per page property * revert and private page
1 parent a89ede6 commit 9bd650e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lib/Github/Api/AbstractApi.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ abstract class AbstractApi implements ApiInterface
1919
*/
2020
protected $client;
2121

22+
/**
23+
* The requested page (GitHub pagination).
24+
*
25+
* @var null|int
26+
*/
27+
private $page;
28+
2229
/**
2330
* Number of items per page (GitHub pagination).
2431
*
@@ -38,6 +45,24 @@ public function configure()
3845
{
3946
}
4047

48+
/**
49+
* @return null|int
50+
*/
51+
public function getPage()
52+
{
53+
return $this->page;
54+
}
55+
56+
/**
57+
* @param null|int $page
58+
*/
59+
public function setPage($page)
60+
{
61+
$this->page = (null === $page ? $page : (int) $page);
62+
63+
return $this;
64+
}
65+
4166
/**
4267
* @return null|int
4368
*/
@@ -67,6 +92,9 @@ public function setPerPage($perPage)
6792
*/
6893
protected function get($path, array $parameters = array(), array $requestHeaders = array())
6994
{
95+
if (null !== $this->page && !isset($parameters['page'])) {
96+
$parameters['page'] = $this->page;
97+
}
7098
if (null !== $this->perPage && !isset($parameters['per_page'])) {
7199
$parameters['per_page'] = $this->perPage;
72100
}

0 commit comments

Comments
 (0)