Skip to content
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

CBP tickets #511

Merged
merged 8 commits into from
Oct 18, 2023
Merged

CBP tickets #511

merged 8 commits into from
Oct 18, 2023

Conversation

ecoologic
Copy link
Contributor

@ecoologic ecoologic commented Oct 11, 2023

Introducing CBP Iterator for Tickets.

This will be generalized in coming PR.

Usage: See README and tests, but basically:

$ticketsIterator = $client->tickets()->iterator();
foreach ($ticketsIterator as $ticket) {
    process($ticket) // Your implementation
}

Note that this PR doesn't address sorting and other params yet. It will be added in a different iteration.

@ecoologic ecoologic force-pushed the RED-1952-cbp-tickets branch 3 times, most recently from 34a073e to e913988 Compare October 17, 2023 05:05
@ecoologic ecoologic requested review from 7ail and a team October 17, 2023 23:41
@ecoologic ecoologic marked this pull request as ready for review October 17, 2023 23:42
public function valid()
{
if (!isset($this->tickets[$this->position]) && (!$this->started || $this->afterCursor)) {
$this->getPage();
Copy link
Contributor Author

@ecoologic ecoologic Oct 18, 2023

Choose a reason for hiding this comment

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

note we only fetch the next page if we're done with the current one. we don't want to fetch all pages and then do all the processing. This is also in the readme.

*/
public function current()
{
if (!isset($this->tickets[$this->position]) && (!$this->started || $this->afterCursor)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just noted this can be abstracted. I'll do that in my next PR.

/**
* @return Ticket The current ticket, possibly fetching a new page.
*/
public function current()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this, valid, key and other methods are part of the PHP Iterator pattern.

@ecoologic ecoologic merged commit 5bd1d13 into master Oct 18, 2023
2 checks passed
@ecoologic ecoologic deleted the RED-1952-cbp-tickets branch October 18, 2023 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants