Skip to content

Commit 07138eb

Browse files
Added the perPage property for Github pagination
The api client supports the per_page github parameter for api calls. Default is NULL and lets github decide the default (currently 30). $client->setPerPage()
1 parent 383346b commit 07138eb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/Github/Api/AbstractApi.php

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

21+
/**
22+
* number of items per page (GitHub pagination)
23+
*
24+
* @var int
25+
*/
26+
protected $perPage = null;
27+
2128
/**
2229
* @param Client $client
2330
*/
@@ -30,11 +37,31 @@ public function configure()
3037
{
3138
}
3239

40+
/**
41+
* @return int|null
42+
*/
43+
public function getPerPage()
44+
{
45+
return $this->perPage;
46+
}
47+
48+
/**
49+
* @param Client $client
50+
*/
51+
public function setPerPage($perPage)
52+
{
53+
$this->perPage = (int) $perPage;
54+
return $this;
55+
}
56+
3357
/**
3458
* {@inheritDoc}
3559
*/
3660
protected function get($path, array $parameters = array(), $requestHeaders = array())
3761
{
62+
if (null !== $this->perPage && !isset($parameters['per_page'])) {
63+
$parameters['per_page'] = $this->perPage;
64+
}
3865
$response = $this->client->getHttpClient()->get($path, $parameters, $requestHeaders);
3966

4067
return $response->getContent();

0 commit comments

Comments
 (0)