Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Dec 12, 2024
1 parent 8c56845 commit 9f693e4
Show file tree
Hide file tree
Showing 67 changed files with 218 additions and 215 deletions.
1 change: 1 addition & 0 deletions docs/requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ To send a request using the Mollie API client, you typically need to:

3. **Send the request**:
Use the client to send the request and handle the response.

```php
use Mollie\Api\MollieApiClient;
use Mollie\Api\Http\Data\Money;
Expand Down
38 changes: 19 additions & 19 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -361,37 +361,37 @@ parameters:
path: tests/Fixtures/MockResponse.php

-
message: '#^Property Tests\\Helpers\\TestPropertiesClass\:\:\$privateProp is unused\.$#'
identifier: property.unused
count: 1
path: tests/Helpers/HelpersTest.php
message: '#^Unsafe access to private property Tests\\Http\\Adapter\\MockMollieHttpAdapter\:\:\$factories through static\:\:\.$#'
identifier: staticClassAccess.privateProperty
count: 3
path: tests/Http/Adapter/MockMollieHttpAdapter.php

-
message: '#^Trait Tests\\Helpers\\TestTraitBase is used zero times and is not analysed\.$#'
identifier: trait.unused
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#'
identifier: method.alreadyNarrowedType
count: 1
path: tests/Helpers/HelpersTest.php
path: tests/Http/Middleware/GuardResponseTest.php

-
message: '#^Trait Tests\\Helpers\\TestTraitMain is used zero times and is not analysed\.$#'
identifier: trait.unused
message: '#^Property Tests\\Utils\\TestPropertiesClass\:\:\$privateProp is unused\.$#'
identifier: property.unused
count: 1
path: tests/Helpers/HelpersTest.php
path: tests/Utils/UtilityTest.php

-
message: '#^Trait Tests\\Helpers\\TestTraitNested is used zero times and is not analysed\.$#'
message: '#^Trait Tests\\Utils\\TestTraitBase is used zero times and is not analysed\.$#'
identifier: trait.unused
count: 1
path: tests/Helpers/HelpersTest.php
path: tests/Utils/UtilityTest.php

-
message: '#^Unsafe access to private property Tests\\Http\\Adapter\\MockMollieHttpAdapter\:\:\$factories through static\:\:\.$#'
identifier: staticClassAccess.privateProperty
count: 3
path: tests/Http/Adapter/MockMollieHttpAdapter.php
message: '#^Trait Tests\\Utils\\TestTraitMain is used zero times and is not analysed\.$#'
identifier: trait.unused
count: 1
path: tests/Utils/UtilityTest.php

-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#'
identifier: method.alreadyNarrowedType
message: '#^Trait Tests\\Utils\\TestTraitNested is used zero times and is not analysed\.$#'
identifier: trait.unused
count: 1
path: tests/Http/Middleware/GuardResponseTest.php
path: tests/Utils/UtilityTest.php
4 changes: 2 additions & 2 deletions src/Contracts/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\Api\Contracts;

use Mollie\Api\Helpers\MiddlewareHandlers;
use Mollie\Api\Http\Middleware;
use Mollie\Api\Http\Request;

interface Connector extends Authenticatable, Hydratable, IdempotencyContract, SupportsDebuggingContract, Testable
Expand All @@ -15,7 +15,7 @@ public function headers(): ArrayRepository;

public function query(): ArrayRepository;

public function middleware(): MiddlewareHandlers;
public function middleware(): Middleware;

public function addVersionString($versionString): self;

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

namespace Mollie\Api\Contracts;

use Mollie\Api\Helpers\Factories;
use Mollie\Api\Utils\Factories;
use Mollie\Api\Http\PendingRequest;
use Mollie\Api\Http\Response;

Expand Down
8 changes: 4 additions & 4 deletions src/EndpointCollection/BalanceEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Factories\GetPaginatedBalanceQueryFactory;
use Mollie\Api\Helpers;
use Mollie\Api\Utils\Utility;
use Mollie\Api\Http\Requests\GetBalanceRequest;
use Mollie\Api\Http\Requests\GetPaginatedBalanceRequest;
use Mollie\Api\Resources\Balance;
Expand All @@ -24,7 +24,7 @@ class BalanceEndpointCollection extends EndpointCollection
*/
public function get(string $id, $testmode = []): Balance
{
$testmode = Helpers::extractBool($testmode, 'testmode', false);
$testmode = Utility::extractBool($testmode, 'testmode', false);

/** @var Balance */
return $this->send((new GetBalanceRequest($id))->test($testmode));
Expand All @@ -48,7 +48,7 @@ public function primary(array $testmode = []): Balance
*/
public function page(?string $from = null, ?int $limit = null, array $filters = []): BalanceCollection
{
$testmode = Helpers::extractBool($filters, 'testmode', false);
$testmode = Utility::extractBool($filters, 'testmode', false);

$query = GetPaginatedBalanceQueryFactory::new([
'from' => $from,
Expand All @@ -67,7 +67,7 @@ public function page(?string $from = null, ?int $limit = null, array $filters =
*/
public function iterator(?string $from = null, ?int $limit = null, array $filters = [], bool $iterateBackwards = false): LazyCollection
{
$testmode = Helpers::extractBool($filters, 'testmode', false);
$testmode = Utility::extractBool($filters, 'testmode', false);

$query = GetPaginatedBalanceQueryFactory::new([
'from' => $from,
Expand Down
4 changes: 2 additions & 2 deletions src/EndpointCollection/BalanceReportEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Mollie\Api\EndpointCollection;

use Mollie\Api\Factories\GetBalanceReportQueryFactory;
use Mollie\Api\Helpers;
use Mollie\Api\Utils\Utility;
use Mollie\Api\Http\Data\GetBalanceReportQuery;
use Mollie\Api\Http\Requests\GetBalanceReportRequest;
use Mollie\Api\Resources\Balance;
Expand All @@ -20,7 +20,7 @@ class BalanceReportEndpointCollection extends EndpointCollection
*/
public function getForId(string $balanceId, $query = []): ?BalanceReport
{
$testmode = Helpers::extractBool($query, 'testmode', false);
$testmode = Utility::extractBool($query, 'testmode', false);

$query = GetBalanceReportQueryFactory::new($query)
->create();
Expand Down
6 changes: 3 additions & 3 deletions src/EndpointCollection/ChargebackEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Factories\GetPaginatedChargebackQueryFactory;
use Mollie\Api\Helpers;
use Mollie\Api\Utils\Utility;
use Mollie\Api\Http\Requests\GetPaginatedChargebacksRequest;
use Mollie\Api\Resources\ChargebackCollection;
use Mollie\Api\Resources\LazyCollection;
Expand All @@ -20,7 +20,7 @@ class ChargebackEndpointCollection extends EndpointCollection
*/
public function page(?string $from = null, ?int $limit = null, array $filters = []): ChargebackCollection
{
$testmode = Helpers::extractBool($filters, 'testmode', false);
$testmode = Utility::extractBool($filters, 'testmode', false);

$query = GetPaginatedChargebackQueryFactory::new([
'from' => $from,
Expand All @@ -41,7 +41,7 @@ public function page(?string $from = null, ?int $limit = null, array $filters =
*/
public function iterator(?string $from = null, ?int $limit = null, $filters = [], bool $iterateBackwards = false): LazyCollection
{
$testmode = Helpers::extractBool($filters, 'testmode', false);
$testmode = Utility::extractBool($filters, 'testmode', false);

$query = GetPaginatedChargebackQueryFactory::new([
'from' => $from,
Expand Down
12 changes: 6 additions & 6 deletions src/EndpointCollection/CustomerEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Mollie\Api\Factories\CreateCustomerPayloadFactory;
use Mollie\Api\Factories\PaginatedQueryFactory;
use Mollie\Api\Factories\UpdateCustomerPayloadFactory;
use Mollie\Api\Helpers;
use Mollie\Api\Utils\Utility;
use Mollie\Api\Http\Data\CreateCustomerPayload;
use Mollie\Api\Http\Data\UpdateCustomerPayload;
use Mollie\Api\Http\Requests\CreateCustomerRequest;
Expand All @@ -30,7 +30,7 @@ class CustomerEndpointCollection extends EndpointCollection
*/
public function create($data = [], $testmode = []): Customer
{
$testmode = Helpers::extractBool($testmode, 'testmode', false);
$testmode = Utility::extractBool($testmode, 'testmode', false);

if (! $data instanceof CreateCustomerPayload) {
$data = CreateCustomerPayloadFactory::new($data)->create();
Expand All @@ -51,7 +51,7 @@ public function create($data = [], $testmode = []): Customer
*/
public function get(string $id, $testmode = []): Customer
{
$testmode = Helpers::extractBool($testmode, 'testmode', false);
$testmode = Utility::extractBool($testmode, 'testmode', false);

/** @var Customer */
return $this->send((new GetCustomerRequest($id))->test($testmode));
Expand Down Expand Up @@ -86,7 +86,7 @@ public function update(string $id, $data = []): ?Customer
*/
public function delete(string $id, $testmode = []): void
{
$testmode = Helpers::extractBool($testmode, 'testmode', false);
$testmode = Utility::extractBool($testmode, 'testmode', false);

$this->send((new DeleteCustomerRequest($id))->test($testmode));
}
Expand All @@ -100,7 +100,7 @@ public function delete(string $id, $testmode = []): void
*/
public function page(?string $from = null, ?int $limit = null, array $filters = []): CustomerCollection
{
$testmode = Helpers::extractBool($filters, 'testmode', false);
$testmode = Utility::extractBool($filters, 'testmode', false);

$query = PaginatedQueryFactory::new([
'from' => $from,
Expand All @@ -120,7 +120,7 @@ public function page(?string $from = null, ?int $limit = null, array $filters =
*/
public function iterator(?string $from = null, ?int $limit = null, array $filters = [], bool $iterateBackwards = false): LazyCollection
{
$testmode = Helpers::extractBool($filters, 'testmode', false);
$testmode = Utility::extractBool($filters, 'testmode', false);

$query = PaginatedQueryFactory::new([
'from' => $from,
Expand Down
10 changes: 5 additions & 5 deletions src/EndpointCollection/CustomerPaymentsEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Factories\CreatePaymentPayloadFactory;
use Mollie\Api\Factories\GetPaginatedCustomerPaymentsQueryFactory;
use Mollie\Api\Helpers;
use Mollie\Api\Helpers\Arr;
use Mollie\Api\Utils\Utility;
use Mollie\Api\Utils\Arr;
use Mollie\Api\Http\Data\CreatePaymentPayload;
use Mollie\Api\Http\Data\CreatePaymentQuery;
use Mollie\Api\Http\Requests\CreateCustomerPaymentRequest;
Expand Down Expand Up @@ -43,7 +43,7 @@ public function createFor(Customer $customer, $payload = [], $query = [], bool $
public function createForId($customerId, $payload = [], $query = [], bool $testmode = false): Payment
{
if (! $payload instanceof CreatePaymentPayload) {
$testmode = Helpers::extractBool($payload, 'testmode', $testmode);
$testmode = Utility::extractBool($payload, 'testmode', $testmode);
$payload = CreatePaymentPayloadFactory::new($payload)
->create();
}
Expand Down Expand Up @@ -73,7 +73,7 @@ public function pageFor(Customer $customer, ?string $from = null, ?int $limit =
*/
public function pageForId(string $customerId, ?string $from = null, ?int $limit = null, array $filters = []): PaymentCollection
{
$testmode = Helpers::extractBool($filters, 'testmode', false);
$testmode = Utility::extractBool($filters, 'testmode', false);
$query = GetPaginatedCustomerPaymentsQueryFactory::new([
'from' => $from,
'limit' => $limit,
Expand Down Expand Up @@ -115,7 +115,7 @@ public function iteratorForId(
array $filters = [],
bool $iterateBackwards = false
): LazyCollection {
$testmode = Helpers::extractBool($filters, 'testmode', false);
$testmode = Utility::extractBool($filters, 'testmode', false);
$query = GetPaginatedCustomerPaymentsQueryFactory::new([
'from' => $from,
'limit' => $limit,
Expand Down
12 changes: 6 additions & 6 deletions src/EndpointCollection/MandateEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Factories\CreateMandatePayloadFactory;
use Mollie\Api\Factories\PaginatedQueryFactory;
use Mollie\Api\Helpers;
use Mollie\Api\Utils\Utility;
use Mollie\Api\Http\Data\CreateMandatePayload;
use Mollie\Api\Http\Requests\CreateMandateRequest;
use Mollie\Api\Http\Requests\GetMandateRequest;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function createFor(Customer $customer, $payload = [], bool $testmode = fa
public function createForId(string $customerId, $payload = [], bool $testmode = false): Mandate
{
if (! $payload instanceof CreateMandatePayload) {
$testmode = Helpers::extractBool($payload, 'testmode', $testmode);
$testmode = Utility::extractBool($payload, 'testmode', $testmode);
$payload = CreateMandatePayloadFactory::new($payload)->create();
}

Expand Down Expand Up @@ -68,7 +68,7 @@ public function getFor(Customer $customer, string $mandateId, array $parameters
*/
public function getForId(string $customerId, string $mandateId, $testmode = []): Mandate
{
$testmode = Helpers::extractBool($testmode, 'testmode', false);
$testmode = Utility::extractBool($testmode, 'testmode', false);

/** @var Mandate */
return $this->send((new GetMandateRequest($customerId, $mandateId))->test($testmode));
Expand All @@ -94,7 +94,7 @@ public function revokeFor(Customer $customer, string $mandateId, $data = []): vo
*/
public function revokeForId(string $customerId, string $mandateId, $testmode = []): void
{
$testmode = Helpers::extractBool($testmode, 'testmode', false);
$testmode = Utility::extractBool($testmode, 'testmode', false);

$this->send((new RevokeMandateRequest($customerId, $mandateId))->test($testmode));
}
Expand All @@ -120,7 +120,7 @@ public function pageFor(Customer $customer, ?string $from = null, ?int $limit =
*/
public function pageForId(string $customerId, ?string $from = null, ?int $limit = null, array $filters = []): MandateCollection
{
$testmode = Helpers::extractBool($filters, 'testmode', false);
$testmode = Utility::extractBool($filters, 'testmode', false);
$query = PaginatedQueryFactory::new([
'from' => $from,
'limit' => $limit,
Expand Down Expand Up @@ -160,7 +160,7 @@ public function iteratorForId(
array $filters = [],
bool $iterateBackwards = false
): LazyCollection {
$testmode = Helpers::extractBool($filters, 'testmode', false);
$testmode = Utility::extractBool($filters, 'testmode', false);
$query = PaginatedQueryFactory::new([
'from' => $from,
'limit' => $limit,
Expand Down
6 changes: 3 additions & 3 deletions src/EndpointCollection/MethodEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Mollie\Api\Factories\GetAllPaymentMethodsQueryFactory;
use Mollie\Api\Factories\GetEnabledPaymentMethodsQueryFactory;
use Mollie\Api\Factories\GetPaymentMethodQueryFactory;
use Mollie\Api\Helpers;
use Mollie\Api\Utils\Utility;
use Mollie\Api\Http\Data\GetAllMethodsQuery as GetAllPaymentMethodsQuery;
use Mollie\Api\Http\Data\GetEnabledPaymentMethodsQuery;
use Mollie\Api\Http\Data\GetPaymentMethodQuery;
Expand Down Expand Up @@ -47,7 +47,7 @@ public function all($query = []): MethodCollection
public function allEnabled($query = [], bool $testmode = false): MethodCollection
{
if (! $query instanceof GetEnabledPaymentMethodsQuery) {
$testmode = Helpers::extractBool($query, 'testmode', $testmode);
$testmode = Utility::extractBool($query, 'testmode', $testmode);
$query = GetEnabledPaymentMethodsQueryFactory::new($query)
->create();
}
Expand Down Expand Up @@ -76,7 +76,7 @@ public function allActive($query = [], ?bool $testmode = null): MethodCollection
public function get(string $methodId, $query = [], bool $testmode = false): Method
{
if (! $query instanceof GetPaymentMethodQuery) {
$testmode = Helpers::extractBool($query, 'testmode', $testmode);
$testmode = Utility::extractBool($query, 'testmode', $testmode);
$query = GetPaymentMethodQueryFactory::new($query)
->create();
}
Expand Down
4 changes: 2 additions & 2 deletions src/EndpointCollection/OrganizationEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Mollie\Api\EndpointCollection;

use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Helpers;
use Mollie\Api\Utils\Utility;
use Mollie\Api\Http\Requests\GetOrganizationPartnerStatusRequest;
use Mollie\Api\Http\Requests\GetOrganizationRequest;
use Mollie\Api\Resources\Organization;
Expand All @@ -22,7 +22,7 @@ class OrganizationEndpointCollection extends EndpointCollection
*/
public function get(string $id, $testmode = []): Organization
{
$testmode = Helpers::extractBool($testmode, 'testmode', false);
$testmode = Utility::extractBool($testmode, 'testmode', false);

/** @var Organization */
return $this->send((new GetOrganizationRequest($id))->test($testmode));
Expand Down
Loading

0 comments on commit 9f693e4

Please sign in to comment.