Skip to content

Commit 2292a25

Browse files
committed
Test against PHP 8.4
Require PHP >= 7.3 Required Guzzle >= 7 Update phpunit config Fix parsing of account balance object Fix wrong body parsing in SuccessfulResponseParsingException Update readme
1 parent d0d0eaa commit 2292a25

File tree

9 files changed

+38
-35
lines changed

9 files changed

+38
-35
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-20.04
66
strategy:
77
matrix:
8-
php: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
8+
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
99
steps:
1010
- uses: actions/checkout@v2
1111
- run: mkdir -p build/logs

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea/
22
vendor/
3-
.phpunit.result.cache
3+
.phpunit.result.cache
4+
composer.lock

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 4.0.0 - 2025-02-05
4+
* Require at least PHP 7.3.
5+
* Test against PHP 8.4.
6+
* Dropped support for Guzzle 6 (now requires Guzzle 7).
7+
* Updated requirements for `guzzlehttp/oauth-subscriber` to minimum `0.8.1` to address [CVE-2025-21617](https://nvd.nist.gov/vuln/detail/CVE-2025-21617).
8+
39
## 3.3.1 - 2024-09-02
410
* Test against PHP 8.3.
511
* Round the total cost of messages to 5 decimal points.

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"description": "PHP library based on Guzzle for integration with gatewayapi.com",
44
"type": "library",
55
"require": {
6-
"php": "^7.1 || ^8.0",
6+
"php": "^7.3 || ^8.0",
77
"ext-json": "*",
8-
"guzzlehttp/guzzle": "^6.0 || ^7.0",
9-
"guzzlehttp/oauth-subscriber": "0.3.* || 0.4.* || 0.5.* || 0.6.*"
8+
"guzzlehttp/guzzle": "^7.0",
9+
"guzzlehttp/oauth-subscriber": "~0.8.1"
1010
},
1111
"require-dev": {
12-
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
13-
"php-coveralls/php-coveralls": "^v2.5.2"
12+
"phpunit/phpunit": "^9.0",
13+
"php-coveralls/php-coveralls": "^v2.7.0"
1414
},
1515
"license": "mit",
1616
"authors": [

phpunit.xml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
bootstrap="vendor/autoload.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false"
3+
bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true"
4+
convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false"
5+
stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
6+
<coverage>
7+
<include>
8+
<directory>./src/</directory>
9+
</include>
10+
<exclude>
11+
<file>./src/Exceptions/ConnectionException.php</file>
12+
</exclude>
13+
<report>
14+
<clover outputFile="build/logs/clover.xml"/>
15+
</report>
16+
</coverage>
1117
<testsuites>
1218
<testsuite name="Test">
1319
<directory>./tests/</directory>
1420
</testsuite>
1521
</testsuites>
16-
<filter>
17-
<whitelist>
18-
<directory>./src/</directory>
19-
<exclude>
20-
<file>./src/Exceptions/ConnectionException.php</file>
21-
</exclude>
22-
</whitelist>
23-
</filter>
24-
<logging>
25-
<log type="coverage-clover" target="build/logs/clover.xml"/>
26-
</logging>
27-
</phpunit>
22+
<logging/>
23+
</phpunit>

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Coverage Status](https://coveralls.io/repos/github/nickdnk/gatewayapi-php/badge.svg?branch=master)](https://coveralls.io/github/nickdnk/gatewayapi-php?branch=master)
33
# GatewayAPI PHP Library
44

5-
This library will allow you to integrate the **GatewayAPI.com** API in your project using modern PHP7 and an OOP structure.
5+
This library will allow you to integrate the **GatewayAPI.com** API in your project using modern PHP.
66
For full description of their API, error codes and so on, see: <https://gatewayapi.com/docs>.
77

88
### Prerequisites
@@ -15,7 +15,7 @@ Once you have that you need to generate an API key/secret pair under **API** ->
1515

1616
To include this in your project, install it using Composer.
1717

18-
This library requires PHP >= 7.1 and works on 8.0, 8.1 and 8.2.
18+
This library requires PHP >= 7.3 and is tested against 8.0, 8.1, 8.2, 8.3 and 8.4.
1919

2020
`composer require nickdnk/gatewayapi-php`
2121

src/Entities/Constructable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static function constructFromResponse(ResponseInterface $response)
6767
} catch (InvalidArgumentException $exception) {
6868

6969
throw new SuccessfulResponseParsingException(
70-
'Failed to construct \'' . static::class . '\' from: ' . json_encode($response->getBody()), $response
70+
'Failed to construct \'' . static::class . '\' from: ' . $response->getBody(), $response
7171
);
7272

7373
}

src/Entities/Response/AccountBalance.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ public function getId(): int
6969
public static function constructFromArray(array $array): AccountBalance
7070
{
7171

72+
// Apparently credit is now a string, but used to be a float.
7273
if (array_key_exists('credit', $array)
7374
&& array_key_exists('currency', $array)
7475
&& array_key_exists('id', $array)
75-
&& is_float($array['credit'])
76+
&& (is_float($array['credit']) || is_string($array['credit']))
7677
&& is_string($array['currency'])
7778
&& is_integer($array['id'])) {
7879

79-
return new AccountBalance($array['credit'], $array['currency'], $array['id']);
80+
return new AccountBalance((float)$array['credit'], $array['currency'], $array['id']);
8081

8182
}
8283

8384
throw new InvalidArgumentException('Array passed to ' . self::class . ' is missing required parameters.');
8485

8586
}
8687
}
87-

tests/AccountBalanceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function testConstructFromResponse()
1717
$response = new Response(
1818
200, [], json_encode(
1919
[
20-
'credit' => 1453.55,
20+
'credit' => '1453.55',
2121
'currency' => 'eur',
2222
'id' => 1232323
2323
]

0 commit comments

Comments
 (0)