-
-
Notifications
You must be signed in to change notification settings - Fork 598
[3.x] Re-worked pagination to not mutate the api classes #907
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,79 +6,59 @@ | |
use Github\HttpClient\Message\ResponseMediator; | ||
|
||
/** | ||
* Abstract class for Api classes. | ||
* | ||
* @author Joseph Bielawski <[email protected]> | ||
* @author Graham Campbell <[email protected]> | ||
*/ | ||
abstract class AbstractApi implements ApiInterface | ||
abstract class AbstractApi | ||
{ | ||
/** | ||
* The client. | ||
* The client instance. | ||
* | ||
* @var Client | ||
*/ | ||
protected $client; | ||
private $client; | ||
|
||
/** | ||
* The requested page (GitHub pagination). | ||
* The per page parameter. | ||
* | ||
* @var null|int | ||
* @var int|null | ||
*/ | ||
private $page; | ||
private $perPage; | ||
|
||
/** | ||
* Number of items per page (GitHub pagination). | ||
* Create a new API instance. | ||
* | ||
* @var null|int | ||
*/ | ||
protected $perPage; | ||
|
||
/** | ||
* @param Client $client | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Client $client) | ||
{ | ||
$this->client = $client; | ||
} | ||
|
||
public function configure() | ||
{ | ||
} | ||
|
||
/** | ||
* @return null|int | ||
*/ | ||
public function getPage() | ||
{ | ||
return $this->page; | ||
} | ||
|
||
/** | ||
* @param null|int $page | ||
* Get the client instance. | ||
* | ||
* @return Client | ||
*/ | ||
public function setPage($page) | ||
protected function getClient() | ||
{ | ||
$this->page = (null === $page ? $page : (int) $page); | ||
|
||
return $this; | ||
return $this->client; | ||
} | ||
|
||
/** | ||
* @return null|int | ||
* Get the API version. | ||
* | ||
* @return string | ||
*/ | ||
public function getPerPage() | ||
protected function getApiVersion() | ||
{ | ||
return $this->perPage; | ||
return $this->client->getApiVersion(); | ||
} | ||
|
||
/** | ||
* @param null|int $perPage | ||
*/ | ||
public function setPerPage($perPage) | ||
public function configure() | ||
{ | ||
$this->perPage = (null === $perPage ? $perPage : (int) $perPage); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
|
@@ -92,12 +72,10 @@ public function setPerPage($perPage) | |
*/ | ||
protected function get($path, array $parameters = [], array $requestHeaders = []) | ||
{ | ||
if (null !== $this->page && !isset($parameters['page'])) { | ||
$parameters['page'] = $this->page; | ||
} | ||
if (null !== $this->perPage && !isset($parameters['per_page'])) { | ||
$parameters['per_page'] = $this->perPage; | ||
} | ||
|
||
if (array_key_exists('ref', $parameters) && null === $parameters['ref']) { | ||
unset($parameters['ref']); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.