Skip to content

Fix Pagination issue #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

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

you should gitignore dev tool specific files and such in your system configuration ignore, not in a project ignore. and you can sefely ignore .idea/ instead of separate files.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this.


test_client.php
2 changes: 2 additions & 0 deletions lib/Github/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Client
'api_limit' => 5000,
'api_version' => 'beta',

'per_page' => 500,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not 30? That is the default from github.. and the limit is 100...
http://developer.github.com/v3/#pagination

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be 30 as it's default value or null as it's not required by GH.


'cache_dir' => null
);

Expand Down
8 changes: 7 additions & 1 deletion lib/Github/HttpClient/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class HttpClient implements HttpClientInterface
'api_limit' => 5000,
'api_version' => 'beta',

'per_page' => 500,

'cache_dir' => null
);
/**
Expand Down Expand Up @@ -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){
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be different, this should go to setOption() not in get().

$parameters['per_page'] = $this->options['per_page'];
}

if (0 < count($parameters)) {
$path .= (false === strpos($path, '?') ? '?' : '&').http_build_query($parameters, '', '&');
}


Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this.

return $this->request($path, array(), 'GET', $headers);
}

Expand Down Expand Up @@ -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) {
Expand Down