Skip to content

Commit

Permalink
by default set $testmode = false instead of empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Jan 6, 2025
1 parent 384d1b3 commit e38f256
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 37 deletions.
5 changes: 3 additions & 2 deletions src/EndpointCollection/BalanceEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BalanceEndpointCollection extends EndpointCollection
*
* @throws ApiException
*/
public function get(string $id, $testmode = []): Balance
public function get(string $id, $testmode = false): Balance
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand All @@ -35,9 +35,10 @@ public function get(string $id, $testmode = []): Balance
*
* Will throw an ApiException if the balance id is invalid or the resource cannot be found.
*
* @param bool|array $testmode
* @throws ApiException
*/
public function primary(array $testmode = []): Balance
public function primary($testmode = false): Balance
{
/** @var Balance */
return $this->get('primary', $testmode);
Expand Down
6 changes: 3 additions & 3 deletions src/EndpointCollection/CustomerEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CustomerEndpointCollection extends EndpointCollection
*
* @throws ApiException
*/
public function create($data = [], $testmode = []): Customer
public function create($data = [], $testmode = false): Customer
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand All @@ -49,7 +49,7 @@ public function create($data = [], $testmode = []): Customer
*
* @throws ApiException
*/
public function get(string $id, $testmode = []): Customer
public function get(string $id, $testmode = false): Customer
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand Down Expand Up @@ -84,7 +84,7 @@ public function update(string $id, $data = []): ?Customer
*
* @throws ApiException
*/
public function delete(string $id, $testmode = []): void
public function delete(string $id, $testmode = false): void
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand Down
6 changes: 3 additions & 3 deletions src/EndpointCollection/MandateEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public function getFor(Customer $customer, string $mandateId, array $parameters
/**
* Retrieve a specific mandate for a customer ID.
*
* @param array $testmode
* @param bool|array $testmode
*
* @throws ApiException
*/
public function getForId(string $customerId, string $mandateId, $testmode = []): Mandate
public function getForId(string $customerId, string $mandateId, $testmode = false): Mandate
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand All @@ -92,7 +92,7 @@ public function revokeFor(Customer $customer, string $mandateId, $data = []): vo
*
* @throws ApiException
*/
public function revokeForId(string $customerId, string $mandateId, $testmode = []): void
public function revokeForId(string $customerId, string $mandateId, $testmode = false): void
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand Down
8 changes: 4 additions & 4 deletions src/EndpointCollection/OrganizationEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class OrganizationEndpointCollection extends EndpointCollection
*
* Will throw a ApiException if the organization id is invalid or the resource cannot be found.
*
* @param array|bool $testmode
* @param bool|array $testmode
*
* @throws ApiException
*/
public function get(string $id, $testmode = []): Organization
public function get(string $id, $testmode = false): Organization
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand All @@ -31,11 +31,11 @@ public function get(string $id, $testmode = []): Organization
/**
* Retrieve the current organization from Mollie.
*
* @param array|bool $testmode
* @param bool|array $testmode
*
* @throws ApiException
*/
public function current($testmode = []): Organization
public function current($testmode = false): Organization
{
/** @var Organization */
return $this->get('me', $testmode);
Expand Down
8 changes: 4 additions & 4 deletions src/EndpointCollection/PaymentLinkEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public function create($payload = []): PaymentLink
*
* Will throw an ApiException if the payment link id is invalid or the resource cannot be found.
*
* @param array $testmode
* @param bool|array $testmode
*
* @throws ApiException
*/
public function get(string $paymentLinkId, $testmode = []): PaymentLink
public function get(string $paymentLinkId, $testmode = false): PaymentLink
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand Down Expand Up @@ -86,11 +86,11 @@ public function delete(string $paymentLinkId, bool $testmode = false): void
* Retrieves a collection of Payment Links from Mollie.
*
* @param string|null $from The first payment link ID you want to include in your list.
* @param array|bool $testmode
* @param bool|array $testmode
*
* @throws ApiException
*/
public function page(?string $from = null, ?int $limit = null, $testmode = []): PaymentLinkCollection
public function page(?string $from = null, ?int $limit = null, $testmode = false): PaymentLinkCollection
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand Down
14 changes: 8 additions & 6 deletions src/EndpointCollection/PaymentRefundEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,27 @@ class PaymentRefundEndpointCollection extends EndpointCollection
/**
* Creates a refund for a specific payment.
*
* @param array|bool $testmode
* @param bool|array $testmode
*
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function createFor(Payment $payment, array $data, $testmode = []): Refund
public function createFor(Payment $payment, array $data, $testmode = false): Refund
{
return $this->createForId($payment->id, $data, $testmode);
}

/**
* Creates a refund for a specific payment.
*
* @param array $payload
* @param array|CreateRefundPaymentPayload $payload
* @param bool|array $testmode
*
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function createForId(string $paymentId, $payload = [], $testmode = []): Refund
public function createForId(string $paymentId, $payload = [], $testmode = false): Refund
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

if (! $payload instanceof CreateRefundPaymentPayload) {
$testmode = Utility::extractBool($payload, 'testmode', $testmode);
$payload = CreateRefundPaymentPayloadFactory::new($payload)
Expand Down Expand Up @@ -82,7 +84,7 @@ public function getForId(string $paymentId, string $refundId, $query = [], bool
*
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function cancelForPayment(Payment $payment, string $refundId, $testmode = [])
public function cancelForPayment(Payment $payment, string $refundId, $testmode = false)
{
return $this->cancelForId($payment->id, $refundId, $testmode);
}
Expand All @@ -93,7 +95,7 @@ public function cancelForPayment(Payment $payment, string $refundId, $testmode =
*
* @throws \Mollie\Api\Exceptions\ApiException
*/
public function cancelForId(string $paymentId, string $refundId, $testmode = [])
public function cancelForId(string $paymentId, string $refundId, $testmode = false)
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand Down
4 changes: 2 additions & 2 deletions src/EndpointCollection/PermissionEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class PermissionEndpointCollection extends EndpointCollection
*
* Will throw an ApiException if the permission id is invalid.
*
* @param array|bool $testmode
* @param bool|array $testmode
*
* @throws ApiException
*/
public function get(string $permissionId, $testmode = []): Permission
public function get(string $permissionId, $testmode = false): Permission
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand Down
8 changes: 4 additions & 4 deletions src/EndpointCollection/ProfileEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public function create($payload = []): Profile
*
* Will throw an ApiException if the profile id is invalid or the resource cannot be found.
*
* @param array|bool $testmode
* @param bool|array $testmode
* @return Profile|CurrentProfile
*
* @throws ApiException
*/
public function get(string $profileId, $testmode = []): Profile
public function get(string $profileId, $testmode = false): Profile
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand All @@ -60,11 +60,11 @@ public function get(string $profileId, $testmode = []): Profile
/**
* Retrieve the current Profile from Mollie.
*
* @param array|bool $testmode
* @param bool|array $testmode
*
* @throws ApiException
*/
public function getCurrent($testmode = []): CurrentProfile
public function getCurrent($testmode = false): CurrentProfile
{
$testmode = Utility::extractBool($testmode, 'testmode', false);

Expand Down
6 changes: 4 additions & 2 deletions src/EndpointCollection/SubscriptionEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ class SubscriptionEndpointCollection extends EndpointCollection
*
* @throws ApiException
*/
public function getFor(Customer $customer, string $subscriptionId, $testmode = []): Subscription
public function getFor(Customer $customer, string $subscriptionId, $testmode = false): Subscription
{
return $this->getForId($customer->id, $subscriptionId, $testmode);
}

/**
* Retrieve a single subscription from Mollie.
*
* @param bool|array $testmode
*
* @throws ApiException
*/
public function getForId(string $customerId, string $subscriptionId, $testmode = []): Subscription
public function getForId(string $customerId, string $subscriptionId, $testmode = false): Subscription
{
$testmode = Utility::extractBool($testmode, 'testmode');

Expand Down
12 changes: 8 additions & 4 deletions src/EndpointCollection/SubscriptionPaymentEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SubscriptionPaymentEndpointCollection extends EndpointCollection
*
* @throws ApiException
*/
public function pageFor(Subscription $subscription, ?string $from = null, ?int $limit = null, $testmode = []): PaymentCollection
public function pageFor(Subscription $subscription, ?string $from = null, ?int $limit = null, $testmode = false): PaymentCollection
{
return $this->pageForIds($subscription->customerId, $subscription->id, $from, $limit, $testmode);
}
Expand All @@ -40,7 +40,7 @@ public function pageForIds(
string $subscriptionId,
?string $from = null,
?int $limit = null,
$testmode = []
$testmode = false
): PaymentCollection {
$testmode = Utility::extractBool($testmode, 'testmode', false);
$query = PaginatedQueryFactory::new([
Expand All @@ -53,26 +53,30 @@ public function pageForIds(

/**
* Create an iterator for iterating over payments for the given subscription, retrieved from Mollie.
*
* @param bool|array $testmode
*/
public function iteratorFor(
Subscription $subscription,
?string $from = null,
?int $limit = null,
$testmode = [],
$testmode = false,
bool $iterateBackwards = false
): LazyCollection {
return $this->iteratorForIds($subscription->customerId, $subscription->id, $from, $limit, $testmode, $iterateBackwards);
}

/**
* Create an iterator for iterating over payments for the given subscription ID, retrieved from Mollie.
*
* @param bool|array $testmode
*/
public function iteratorForIds(
string $customerId,
string $subscriptionId,
?string $from = null,
?int $limit = null,
$testmode = [],
$testmode = false,
bool $iterateBackwards = false
): LazyCollection {
$testmode = Utility::extractBool($testmode, 'testmode', false);
Expand Down
8 changes: 5 additions & 3 deletions src/EndpointCollection/TerminalEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TerminalEndpointCollection extends EndpointCollection
*
* @throws ApiException
*/
public function get(string $id, $testmode = []): Terminal
public function get(string $id, $testmode = false): Terminal
{
$testmode = Utility::extractBool($testmode, 'testmode');

Expand All @@ -34,10 +34,11 @@ public function get(string $id, $testmode = []): Terminal
* Retrieves a collection of Terminals from Mollie for the current organization / profile, ordered from newest to oldest.
*
* @param string|null $from The first terminal ID you want to include in your list.
* @param bool|array $testmode
*
* @throws ApiException
*/
public function page(?string $from = null, ?int $limit = null, $testmode = []): TerminalCollection
public function page(?string $from = null, ?int $limit = null, $testmode = false): TerminalCollection
{
$testmode = Utility::extractBool($testmode, 'testmode', false);
$query = PaginatedQueryFactory::new([
Expand All @@ -54,11 +55,12 @@ public function page(?string $from = null, ?int $limit = null, $testmode = []):
*
* @param string|null $from The first resource ID you want to include in your list.
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
* @param bool|array $testmode
*/
public function iterator(
?string $from = null,
?int $limit = null,
$testmode = [],
$testmode = false,
bool $iterateBackwards = false
): LazyCollection {
$testmode = Utility::extractBool($testmode, 'testmode', false);
Expand Down

0 comments on commit e38f256

Please sign in to comment.