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/add auto pagination helper methods #702

Merged
merged 26 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix styling
  • Loading branch information
Naoray authored and github-actions[bot] committed Oct 30, 2023
commit 90ad2554588d1117e9fbc6d57edcd4752a117615
2 changes: 1 addition & 1 deletion src/Endpoints/BalanceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Balance;
use Mollie\Api\Resources\BalanceCollection;
use Mollie\Api\Resources\BaseCollection;
use Mollie\Api\Resources\LazyCollection;

class BalanceEndpoint extends CollectionEndpointAbstract
{
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/BalanceTransactionEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Balance;
use Mollie\Api\Resources\BalanceTransaction;
use Mollie\Api\Resources\BalanceTransactionCollection;
use Mollie\Api\Resources\LazyCollection;

class BalanceTransactionEndpoint extends CollectionEndpointAbstract
{
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/ChargebackEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Chargeback;
use Mollie\Api\Resources\ChargebackCollection;
use Mollie\Api\Resources\LazyCollection;

class ChargebackEndpoint extends CollectionEndpointAbstract
{
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/ClientEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Client;
use Mollie\Api\Resources\ClientCollection;
use Mollie\Api\Resources\LazyCollection;

class ClientEndpoint extends CollectionEndpointAbstract
{
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/CollectionEndpointAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\BaseCollection;
use Mollie\Api\Resources\CursorCollection;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\ResourceFactory;

abstract class CollectionEndpointAbstract extends EndpointAbstract
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/CustomerEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Customer;
use Mollie\Api\Resources\CustomerCollection;
use Mollie\Api\Resources\LazyCollection;

class CustomerEndpoint extends CollectionEndpointAbstract
{
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/CustomerPaymentsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Customer;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentCollection;

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/InvoiceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Invoice;
use Mollie\Api\Resources\InvoiceCollection;
use Mollie\Api\Resources\LazyCollection;

class InvoiceEndpoint extends CollectionEndpointAbstract
{
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/MandateEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Customer;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Mandate;
use Mollie\Api\Resources\MandateCollection;

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/OrderEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Order;
use Mollie\Api\Resources\OrderCollection;

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/PaymentCaptureEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Capture;
use Mollie\Api\Resources\CaptureCollection;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;

class PaymentCaptureEndpoint extends CollectionEndpointAbstract
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/PaymentChargebackEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Chargeback;
use Mollie\Api\Resources\ChargebackCollection;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;

class PaymentChargebackEndpoint extends CollectionEndpointAbstract
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/PaymentEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentCollection;
use Mollie\Api\Resources\Refund;
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/PaymentLinkEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentLink;
use Mollie\Api\Resources\PaymentLinkCollection;
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/ProfileEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\CurrentProfile;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Profile;
use Mollie\Api\Resources\ProfileCollection;

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/RefundEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Refund;
use Mollie\Api\Resources\RefundCollection;

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/SettlementCaptureEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Capture;
use Mollie\Api\Resources\CaptureCollection;
use Mollie\Api\Resources\LazyCollection;

class SettlementCaptureEndpoint extends CollectionEndpointAbstract
{
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/SettlementChargebackEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Chargeback;
use Mollie\Api\Resources\ChargebackCollection;
use Mollie\Api\Resources\LazyCollection;

class SettlementChargebackEndpoint extends CollectionEndpointAbstract
{
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/SettlementsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Settlement;
use Mollie\Api\Resources\SettlementCollection;

Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/TerminalEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Terminal;
use Mollie\Api\Resources\TerminalCollection;

Expand Down
6 changes: 3 additions & 3 deletions src/Resources/CursorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract protected function createResourceObject();
*/
final public function next()
{
if (!$this->hasNext()) {
if (! $this->hasNext()) {
return null;
}

Expand All @@ -60,7 +60,7 @@ final public function next()
*/
final public function previous()
{
if (!$this->hasPrevious()) {
if (! $this->hasPrevious()) {
return null;
}

Expand Down Expand Up @@ -112,7 +112,7 @@ public function getAutoIterator(bool $iterateBackwards = false): LazyCollection
yield $item;
}

if (($iterateBackwards && !$page->hasPrevious()) || !$page->hasNext()) {
if (($iterateBackwards && ! $page->hasPrevious()) || ! $page->hasNext()) {
break;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Resources/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function first(callable $callback = null): mixed
$iterator = $this->getIterator();

if (is_null($callback)) {
if (!$iterator->valid()) {
if (! $iterator->valid()) {
return null;
}

Expand Down Expand Up @@ -113,7 +113,7 @@ public function take(int $limit): static
$iterator = $this->getIterator();

while ($limit--) {
if (!$iterator->valid()) {
if (! $iterator->valid()) {
break;
}

Expand All @@ -131,7 +131,7 @@ public function every(callable $callback): bool
$iterator = $this->getIterator();

foreach ($iterator as $key => $value) {
if (!$callback($value, $key)) {
if (! $callback($value, $key)) {
return false;
}
}
Expand Down