mollie / mollie-api-php

Mollie API client for PHP
http://www.mollie.com
BSD 2-Clause "Simplified" License
552 stars 191 forks source link

Feature/add auto pagination helper methods #702

Closed Naoray closed 11 months ago

Naoray commented 1 year ago

This is a follow up PR of #701 to add helper methods to the auto pagination functionality. Similar to the advanced usage of the nodejs implementation.

In general this PR allows to chain methods onto the getAutoPaginator() method call in order to manipulate items within the collection. The available methods are

This new approach allows for the following usages

$iterator = $client->payments
    ->iterator()
    ->filter(fn (Payment $payment) => $payment->amount->currency === ‘EUR’ && $payment->amount->value > 100)
    ->take(10);

foreach ($iterator as $payment) {
    //…
}