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

[Feature Req.] Implement IteratorAggregate in Collection #575

Closed
stemis opened this issue Jan 3, 2019 · 3 comments
Closed

[Feature Req.] Implement IteratorAggregate in Collection #575

stemis opened this issue Jan 3, 2019 · 3 comments

Comments

@stemis
Copy link

stemis commented Jan 3, 2019

Hello,

I am writing this issue to suggest the use of IteratorAggregate to the Collection class.
I would like to be able to use the Collection as follows:

foreach($customer->sources as $source) {
...
}

Since Collection is not implementing a Traversable, this is currently not possible.

Right now iteration is possible using the following methods:

foreach ($customer->sources->data as $card) {
    ...
 }

// or

foreach ($customer->sources->autoPagingIterator() as $source) {
    ...
 }

Since $collection->autoPagingIterator() is already returning an iterator, it seems like a small request to add the getIterator() required by the IteratorAggregate interface to the Collection class.

Is this something that seems feasible?

Kind Regards,
Steff

@ob-stripe
Copy link
Contributor

Sounds very reasonable! In fact, I thought you could already iterate directly over Collection instances 😄 We'll implement this soon.

@stemis
Copy link
Author

stemis commented Jan 3, 2019

Thanks! Much appreciated 😄

@ob-stripe
Copy link
Contributor

Implemented in 6.28.0.

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

No branches or pull requests

2 participants