link0 / bunq

API client in PHP for bunq
MIT License
8 stars 13 forks source link

WIP: Initial tryout of PaginatedResponse #10

Open dennisdegreef opened 7 years ago

dennisdegreef commented 7 years ago

Currently there is no functionality to make use of the pagination in responses. This pull request attempts to fix this, by using PHP's generators to only do the API call when traversed.

The only problem is that when you'd also want to use \ArrayAccess it shows weird behaviour if implemented.

var_dump(isset($response[30])); // false
foreach ($response as $value) {}
var_dump(isset($response[30])); // true

Note that since the items are added after first recursion traversal, it also acts as a cache, and enabled the array access after traversal up until item X using a for-loop, or up until the last item when using while/foreach.

Any feedback on this implementation is welcome.