Skip to content

Commit

Permalink
fix(php): add support for php 7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
criskell committed Jan 4, 2024
1 parent 67cd8db commit e719a90
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php-version: [7.4, 8.0, 8.1, 8.2]
php-version: [7.3, 7.4, 8.0, 8.1, 8.2]

steps:
- name: Checkout code
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 7.3

- name: Cache Composer dependencies
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
},
"require": {
"php": "^7.4 || ^8.0",
"php": "^7.3 || ^8.0",
"php-http/discovery": "^1.18",
"psr/http-client": "^1.0",
"psr/http-client-implementation": "*",
Expand Down
5 changes: 4 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class Client

public const BASE_URI = "https://api.openpix.com.br";

private RequestTransport $requestTransport;
/**
* @var RequestTransport
*/
private $requestTransport;

/**
* Create a new client from an application ID and base URI (by default is OpenPix).
Expand Down
18 changes: 13 additions & 5 deletions src/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,38 @@ class Paginator implements Iterator
{
/**
* Transport used by HTTP requests.
*
* @var RequestTransport
*/
private RequestTransport $requestTransport;
private $requestTransport;

/**
* Last request sent to API.
*
* @var Request
*/
private Request $listRequest;
private $listRequest;

/**
* Last result from API.
*
* @var array<mixed>|null
*/
private ?array $lastResult;
private $lastResult;

/**
* Amount of resources to be skipped.
*
* @var int
*/
private int $skip = 0;
private $skip = 0;

/**
* Amount of resources per page.
*
* @var int
*/
private int $perPage = 30;
private $perPage = 30;

/**
* Create a new `Paginator` instance.
Expand Down
10 changes: 7 additions & 3 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ class Request
{
/**
* The path to endpoint.
*
* @var string
*/
private string $path;
private $path;

/**
* The HTTP method of endpoint.
*
* @var string
*/
private string $method;
private $method;

/**
* Query parameters to set into URI on request build.
*
* @var array<mixed>
*/
private array $queryParams = [];
private $queryParams = [];

/**
* Body of request.
Expand Down
20 changes: 15 additions & 5 deletions src/RequestTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,38 @@ class RequestTransport

/**
* Underlying HTTP client.
*
* @var ClientInterface
*/
private ClientInterface $httpClient;
private $httpClient;

/**
* Request factory passed to API `Request` builder.
*
* @var RequestFactoryInterface
*/
private RequestFactoryInterface $requestFactory;
private $requestFactory;

/**
* Stream factory passed to API `Request` builder.
*
* @var StreamFactoryInterface
*/
private StreamFactoryInterface $streamFactory;
private $streamFactory;

/**
* Application ID.
*
* @var string
*/
private string $appId;
private $appId;

/**
* Base URI of all requests handled by RequestTransport.
*
* @var string
*/
private string $baseUri;
private $baseUri;

/**
* Create a new RequestTransport instance.
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/Charges.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ class Charges
{
/**
* The transport used by {@see Request}.
*
* @var RequestTransport
*/
private RequestTransport $requestTransport;
private $requestTransport;

/**
* Create a new Charges instance.
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/Customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class Customers
{
/**
* Used to send HTTP requests to customers API.
*
* @var RequestTransport
*/
private RequestTransport $requestTransport;
private $requestTransport;

/**
* Create a new Customers instance.
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class Payments
{
/**
* Used to send HTTP requests to the payments API.
*
* @var RequestTransport
*/
private RequestTransport $requestTransport;
private $requestTransport;

/**
* Create a new Payments instance.
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/Refunds.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class Refunds
{
/**
* Transport used to send HTTP requests.
*
* @var RequestTransport
*/
private RequestTransport $requestTransport;
private $requestTransport;

/**
* Create a new Refunds instance.
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/Subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ class Subscriptions
{
/**
* Used to send HTTP requests.
*
* @var RequestTransport
*/
private RequestTransport $requestTransport;
private $requestTransport;

/**
* Create a new Subscriptions instance.
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/Transactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class Transactions
{
/**
* Used to send HTTP requests to transactions API.
*
* @var RequestTransport
*/
private RequestTransport $requestTransport;
private $requestTransport;

/**
* Create a new Transactions instance.
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/Webhooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ class Webhooks

/**
* Request transport used to send HTTP requests.
*
* @var RequestTransport
*/
private RequestTransport $requestTransport;
private $requestTransport;

/**
* Create a new Webhooks instance.
Expand Down
18 changes: 14 additions & 4 deletions tests/PaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ public function testGetPagedRequest(): void
public function testNext(): void
{
$this->testPaginatorNavigation(
fn (Paginator $paginator) => $paginator->next(),
function (Paginator $paginator): void {
$paginator->next();
},
30
);
}

public function testPrevious(): void
{
$this->testPaginatorNavigation(
fn (Paginator $paginator) => $paginator->previous(),
function (Paginator $paginator): void {
$paginator->previous();
},
0,
30
);
Expand All @@ -41,14 +45,20 @@ public function testPrevious(): void
public function testGo(): void
{
$this->testPaginatorNavigation(
fn (Paginator $paginator) => $paginator->go(2),
function (Paginator $paginator): void {
$paginator->go(2);
},
60
);
}

public function testRewind(): void
{
$this->testPaginatorNavigation(fn (Paginator $paginator) => $paginator->rewind());
$this->testPaginatorNavigation(
function (Paginator $paginator): void {
$paginator->rewind();
}
);
}

public function testKey(): void
Expand Down

0 comments on commit e719a90

Please sign in to comment.