Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8669373
Updated QP to be statically checked and be more in line with PHP ^8.0
iMusicJJ Nov 30, 2021
427578e
Remove build badges
iMusicJJ Nov 30, 2021
25d883b
Add GH Actions
iMusicJJ Dec 1, 2021
92b13c4
Added special Timeout exception
iMusicJJ Dec 1, 2021
d172220
Corrected GH Actions
iMusicJJ Dec 1, 2021
cf77407
Merge pull request #2 from iMusicJJ/feature/better-error-handling
iMusicJJ Dec 1, 2021
a08a8b1
Merge pull request #3 from iMusicJJ/develop
iMusicJJ Dec 1, 2021
28c776f
Move static props to QuickPay Main class
iMusicJJ Dec 1, 2021
66163b6
Merge pull request #4 from iMusicJJ/feature/move-static-props-to-quic…
iMusicJJ Dec 1, 2021
1edc346
Merge pull request #5 from iMusicJJ/develop
iMusicJJ Dec 1, 2021
25c8822
Bump friendsofphp/php-cs-fixer from 3.3.2 to 3.9.4
dependabot[bot] Jul 18, 2022
0c2e577
Merge pull request #13 from iMusicJJ/dependabot/composer/friendsofphp…
iMusicJJ Jul 19, 2022
d77962b
Bump phpunit/phpunit from 9.5.10 to 9.5.23
dependabot[bot] Aug 23, 2022
7970885
Merge pull request #20 from iMusicJJ/dependabot/composer/phpunit/phpu…
iMusicJJ Aug 30, 2022
bfaae87
Bump friendsofphp/php-cs-fixer from 3.9.4 to 3.10.0
dependabot[bot] Aug 30, 2022
b19b884
Bump phpstan/phpstan from 1.2.0 to 1.8.2
dependabot[bot] Aug 30, 2022
84c82f4
Merge pull request #18 from iMusicJJ/dependabot/composer/friendsofphp…
iMusicJJ Aug 30, 2022
aa0de2f
Merge pull request #16 from iMusicJJ/dependabot/composer/phpstan/phps…
iMusicJJ Aug 30, 2022
74e0172
Cleanup and update
iMusicJJ Aug 30, 2022
79311d6
Bump friendsofphp/php-cs-fixer from 3.10.0 to 3.11.0
dependabot[bot] Sep 2, 2022
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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
55 changes: 55 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Static Analysis

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

jobs:
cs:
runs-on: ubuntu-latest

name: Code Style

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
tools: composer:v2
coverage: none

- name: Install Dependencies
run: composer update --no-interaction --no-progress --ansi

- name: Run PHP-CS-Fixer
run: vendor/bin/php-cs-fixer fix -v --allow-risky=yes --dry-run --ansi

phpstan:
runs-on: ubuntu-latest
strategy:
matrix:
dependency-version: [prefer-lowest, prefer-stable]

name: PHPStan ${{ matrix.dependency-version }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
tools: composer:v2
coverage: none

- name: Install Dependencies
run: composer update --prefer-stable --no-interaction --no-progress --ansi

- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress --ansi
47 changes: 47 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Run Tests

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
php: ['8.0', '8.1']
dependency-version: [prefer-lowest, prefer-stable]
exclude:
- php: 8.1
dependency-version: prefer-lowest
- php: 8.1
os: macos-latest
- php: 8.1
os: windows-latest


name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Setup Problem Matches
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install PHP dependencies
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress --ansi

- name: Unit Tests
run: ./vendor/bin/phpunit --colors=always
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
vendor/
composer.phar
.php-cs-fixer.cache
.phpunit.result.cache
29 changes: 29 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . DIRECTORY_SEPARATOR . 'QuickPay')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'Tests')
->append(['.php-cs-fixer.dist.php']);

$rules = [
'@Symfony' => true,
'@PSR2' => true,
'phpdoc_to_comment' => false,
'array_syntax' => ['syntax' => 'short'],
'yoda_style' => false,
'binary_operator_spaces' => [
'operators' => [
'=>' => 'align',
'=' => 'align',
],
],
'concat_space' => ['spacing' => 'one'],
'not_operator_with_space' => false,
];

$rules['increment_style'] = ['style' => 'post'];

return (new PhpCsFixer\Config())
->setUsingCache(true)
->setRules($rules)
->setFinder($finder);
15 changes: 0 additions & 15 deletions .scrutinizer.yml

This file was deleted.

36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

77 changes: 17 additions & 60 deletions QuickPay/API/Client.php
Original file line number Diff line number Diff line change
@@ -1,67 +1,37 @@
<?php

namespace QuickPay\API;

/**
* @class QuickPay_Client
* @since 0.1.0
* @package QuickPay
* @category Class
* @author Patrick Tolvstein, Perfect Solution ApS
* @docs http://tech.quickpay.net/api/
*/
use CurlHandle;
use QuickPay\API\Exceptions\GenericException;

class Client
{
/**
* Contains cURL instance
*
* @access public
*/
public $ch;

/**
* Contains the authentication string
*
* @access protected
*/
protected $auth_string;
public CurlHandle $ch;
protected ?string $auth_string;
protected array $headers = [];

/**
* Contains the headers
*
* @access protected
*/
protected $headers = array();

/**
* __construct function.
*
* Instantiate object
*
* @access public
*/
public function __construct($auth_string = '', $additional_headers = array())
public function __construct(?string $auth_string = '', array $additional_headers = [])
{
// Check if lib cURL is enabled
if (!function_exists('curl_init')) {
throw new Exception('Lib cURL must be enabled on the server');
throw new GenericException('Lib cURL must be enabled on the server');
}

// Save authentication string
$this->auth_string = $auth_string;

// Create cURL instance.
$this->ch = curl_init();
curl_setopt_array($this->ch, array(
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC
));
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
]);

// Default headers
$this->headers = array(
$this->headers = [
'Accept-Version: v10',
'Accept: application/json',
);
];
if (!empty($this->auth_string)) {
$this->headers[] = 'Authorization: Basic ' . base64_encode($this->auth_string);
}
Expand All @@ -70,32 +40,19 @@ public function __construct($auth_string = '', $additional_headers = array())
$this->setHeaders($additional_headers);
}

/**
* Shutdown function.
*
* Closes the current cURL connection
*
* @access public
*/
public function shutdown()
public function shutdown(): void
{
if (!empty($this->ch)) {
curl_close($this->ch);
}
}

/**
* Set additional headers for cURL request.
*
* @param string[] $additional_headers
* @access public
* @return bool
*/
public function setHeaders($additional_headers)
public function setHeaders(array $additional_headers): bool
{
if (!empty($additional_headers)) {
$this->headers = array_merge($this->headers, $additional_headers);
}

return curl_setopt($this->ch, CURLOPT_HTTPHEADER, $this->headers);
}
}
16 changes: 3 additions & 13 deletions QuickPay/API/Constants.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
<?php

namespace QuickPay\API;

/**
* @class QuickPay_Constants
* @since 0.1.0
* @package QuickPay
* @category Class
* @author Patrick Tolvstein, Perfect Solution ApS
* @docs http://tech.quickpay.net/api/
*/
class Constants
{
/**
* API DEFINITIONS
*/
const API_URL = 'https://api.quickpay.net/';
const API_VERSION = '10';
public const API_URL = 'https://api.quickpay.net/';
public const API_VERSION = '10';
}
27 changes: 0 additions & 27 deletions QuickPay/API/Exception.php

This file was deleted.

11 changes: 11 additions & 0 deletions QuickPay/API/Exceptions/GenericException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace QuickPay\API\Exceptions;

class GenericException extends \Exception
{
public function __construct(string $message, int $code = 0, self $previous = null)
{
parent::__construct($message, $code, $previous);
}
}
11 changes: 11 additions & 0 deletions QuickPay/API/Exceptions/TimeoutException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace QuickPay\API\Exceptions;

class TimeoutException extends GenericException
{
public function __construct(string $message, int $code = 0, self $previous = null)
{
parent::__construct($message, $code, $previous);
}
}
Loading