diff --git a/.gitignore b/.gitignore index fbeabd9bcd2..f1d7db7f73f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,21 @@ phpunit.xml composer.lock composer.phar vendor/* + +.idea/.name + +.idea/encodings.xml + +.idea/misc.xml + +.idea/modules.xml + +.idea/php-github-api.iml + +.idea/scopes/scope_settings.xml + +.idea/vcs.xml + +.idea/workspace.xml + +test_client.php diff --git a/lib/Github/Client.php b/lib/Github/Client.php index cafe5554186..b690dd76444 100644 --- a/lib/Github/Client.php +++ b/lib/Github/Client.php @@ -55,6 +55,8 @@ class Client 'api_limit' => 5000, 'api_version' => 'beta', + 'per_page' => 500, + 'cache_dir' => null ); diff --git a/lib/Github/HttpClient/HttpClient.php b/lib/Github/HttpClient/HttpClient.php index ef82a2a0044..dc9b5db5ec0 100644 --- a/lib/Github/HttpClient/HttpClient.php +++ b/lib/Github/HttpClient/HttpClient.php @@ -34,6 +34,8 @@ class HttpClient implements HttpClientInterface 'api_limit' => 5000, 'api_version' => 'beta', + 'per_page' => 500, + 'cache_dir' => null ); /** @@ -119,10 +121,15 @@ public function addListener(ListenerInterface $listener) */ public function get($path, array $parameters = array(), array $headers = array()) { + if(is_int($this->options['per_page']) && $this->options['per_page'] > 0){ + $parameters['per_page'] = $this->options['per_page']; + } + if (0 < count($parameters)) { $path .= (false === strpos($path, '?') ? '?' : '&').http_build_query($parameters, '', '&'); } + return $this->request($path, array(), 'GET', $headers); } @@ -164,7 +171,6 @@ public function put($path, array $parameters = array(), array $headers = array() public function request($path, array $parameters = array(), $httpMethod = 'GET', array $headers = array()) { $path = trim($this->options['base_url'].$path, '/'); - $request = $this->createRequest($httpMethod, $path); $request->addHeaders($headers); if (count($parameters) > 0) {