Skip to content

Commit

Permalink
add LazyCollection methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Oct 30, 2023
1 parent 68c204e commit 1ddf8a5
Show file tree
Hide file tree
Showing 28 changed files with 372 additions and 105 deletions.
6 changes: 3 additions & 3 deletions src/Endpoints/BalanceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Balance;
use Mollie\Api\Resources\BalanceCollection;
Expand Down Expand Up @@ -89,9 +89,9 @@ public function page(?string $from = null, ?int $limit = null, array $parameters
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Endpoints/BalanceTransactionEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Balance;
use Mollie\Api\Resources\BalanceTransaction;
use Mollie\Api\Resources\BalanceTransactionCollection;
Expand Down Expand Up @@ -58,9 +58,9 @@ public function listFor(Balance $balance, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Balance $balance, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Balance $balance, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($balance->id, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -88,9 +88,9 @@ public function listForId(string $balanceId, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $balanceId, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $balanceId, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $balanceId;

Expand Down Expand Up @@ -118,9 +118,9 @@ public function listForPrimary(array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForPrimary(array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForPrimary(array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = "primary";

Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/ChargebackEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Chargeback;
use Mollie\Api\Resources\ChargebackCollection;
Expand Down Expand Up @@ -57,9 +57,9 @@ public function page(?string $from = null, ?int $limit = null, array $parameters
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/ClientEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Client;
use Mollie\Api\Resources\ClientCollection;
Expand Down Expand Up @@ -76,9 +76,9 @@ public function page(?string $from = null, ?int $limit = null, array $parameters
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/CollectionEndpointAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\BaseCollection;
use Mollie\Api\Resources\CursorCollection;
Expand Down Expand Up @@ -49,9 +49,9 @@ protected function rest_list(?string $from = null, ?int $limit = null, array $fi
* @param int $limit
* @param array $filters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
* @return Generator
* @return LazyCollection
*/
protected function rest_iterator(?string $from = null, ?int $limit = null, array $filters = [], bool $iterateBackwards = false): Generator
protected function rest_iterator(?string $from = null, ?int $limit = null, array $filters = [], bool $iterateBackwards = false): LazyCollection
{
/** @var CursorCollection $page */
$page = $this->rest_list($from, $limit, $filters);
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/CustomerEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Customer;
use Mollie\Api\Resources\CustomerCollection;
Expand Down Expand Up @@ -128,9 +128,9 @@ public function page(?string $from = null, ?int $limit = null, array $parameters
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Endpoints/CustomerPaymentsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Customer;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentCollection;
Expand Down Expand Up @@ -89,9 +89,9 @@ public function listFor(Customer $customer, ?string $from = null, ?int $limit =
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($customer->id, $from, $limit, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -121,9 +121,9 @@ public function listForId($customerId, ?string $from = null, ?int $limit = null,
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $customerId;

Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/InvoiceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Invoice;
use Mollie\Api\Resources\InvoiceCollection;
Expand Down Expand Up @@ -86,9 +86,9 @@ public function all(array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Endpoints/MandateEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Customer;
use Mollie\Api\Resources\Mandate;
use Mollie\Api\Resources\MandateCollection;
Expand Down Expand Up @@ -113,9 +113,9 @@ public function listFor(Customer $customer, $from = null, $limit = null, array $
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($customer->id, $from, $limit, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -145,9 +145,9 @@ public function listForId($customerId, $from = null, $limit = null, array $param
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $customerId;

Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/OrderEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Order;
use Mollie\Api\Resources\OrderCollection;
Expand Down Expand Up @@ -137,9 +137,9 @@ public function page(?string $from = null, ?int $limit = null, array $parameters
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Endpoints/PaymentCaptureEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Capture;
use Mollie\Api\Resources\CaptureCollection;
use Mollie\Api\Resources\Payment;
Expand Down Expand Up @@ -115,9 +115,9 @@ public function listFor(Payment $payment, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($payment->id, $from, $limit, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -145,9 +145,9 @@ public function listForId($paymentId, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $paymentId;

Expand Down
10 changes: 5 additions & 5 deletions src/Endpoints/PaymentChargebackEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Chargeback;
use Mollie\Api\Resources\ChargebackCollection;
use Mollie\Api\Resources\Payment;
Expand Down Expand Up @@ -83,9 +83,9 @@ public function listFor(Payment $payment, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($payment->id, $from, $limit, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -113,9 +113,9 @@ public function listForId($paymentId, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $paymentId;

Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/PaymentEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentCollection;
Expand Down Expand Up @@ -149,9 +149,9 @@ public function page($from = null, $limit = null, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/PaymentLinkEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentLink;
Expand Down Expand Up @@ -94,9 +94,9 @@ public function page($from = null, $limit = null, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Endpoints/PaymentRefundEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\Refund;
use Mollie\Api\Resources\RefundCollection;
Expand Down Expand Up @@ -83,9 +83,9 @@ public function listFor(Payment $payment, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($payment->id, $from, $limit, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -113,9 +113,9 @@ public function listForId($paymentId, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $paymentId;

Expand Down
Loading

0 comments on commit 1ddf8a5

Please sign in to comment.