bpolaszek/cartesian-product

Iterators as subsets should be supported

ostrolucky opened this issue · 4 comments

Hey, I've run into your useful library and as far as I see it's the only one that does cartesian products while preserving string keys. However, it does not support Iterator as subsets, because of this exception being thrown

throw new \InvalidArgumentException(sprintf('Key "%s" should return a non-empty array', $key));

My use case is to do cartesian product of two mongodb cursors.

I'm not against it, but the iterator must be countable in order to match with the count method. Would you mind opening a PR for this?

I was hoping you will just delete the method. Code contributions are subject of personal code style and I don't want having to come back to it and rework it.

Validation is needed to ensure the object to work properly. I'll try to give a try to Iterators in a few days.

not sure how useful is exception being thrown over normal php error though. There isn't much value for explicit, manual if there, result is same