Skip to content

Commit

Permalink
Add 8.2 support (#12)
Browse files Browse the repository at this point in the history
* Add PHP 8.2 support
  • Loading branch information
sf-cg authored Jul 21, 2023
1 parent 07b418b commit 87cd59b
Show file tree
Hide file tree
Showing 17 changed files with 261 additions and 46 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

steps:
- uses: actions/checkout@master
Expand All @@ -23,14 +24,11 @@ jobs:
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-version }}
extension-csv: json, xdebug
extensions: json, xdebug, soap
coverage: xdebug

- name: validate composer.json
run: composer validate

- name: install deps
run: composer install --prefer-dist --no-progress --no-suggest

- name: run tests
run: cp -f .env.pipelines .env && composer test
run: cp -f .env.pipelines .env && composer test
35 changes: 35 additions & 0 deletions .github/workflows/composer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Composer

on: [push, pull_request]

jobs:
static-analysis:
name: Composer Scans

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

steps:
- uses: actions/checkout@master

- name: setup php
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-version }}

- name: validate composer.json
run: composer validate

- name: install deps
run: composer install --prefer-dist --no-progress --no-suggest

- name: composer audit
run: composer audit
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint

on: [push, pull_request]

jobs:
static-analysis:
name: Lint

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

steps:
- uses: actions/checkout@master

- name: setup php
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-version }}

- name: install deps
run: composer install --prefer-dist --no-progress --no-suggest

- name: lint
run: composer lint
32 changes: 32 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Static Analysis

on: [push, pull_request]

jobs:
static-analysis:
name: Static Analysis

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

steps:
- uses: actions/checkout@master

- name: setup php
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-version }}

- name: install deps
run: composer install --prefer-dist --no-progress --no-suggest

- name: phpstan
run: composer analyse-ci
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# XCover SDK for PHP

XCover SDK simplifies [XCover API](https://www.covergenius.com/api/docs/xcover/) integration in PHP applications.
The library is based on Guzzle 6 HTTP client and offers the following features:
The library is based on Guzzle 7 HTTP client and offers the following features:

* AuthMiddleware performs authentication
* JsonResponseMiddleware provides convenient `json` method on the Guzzle responses
Expand All @@ -33,7 +33,7 @@ XCover SDK is available on [Packagist](https://packagist.org/packages/covergeniu

V1 releases are for PHP 7.2 or higher (but less than 8)

V2 releases are for PHP 8
V2 releases are for PHP 7.4 as well as 8.0 and higher

```bash
composer require covergenius/xcover-php
Expand Down
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,21 @@
{
"name": "Mith Habib",
"email": "[email protected]"
},
{
"name": "Scott Flack",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.4.0",
"php": "^7.4.0||^8.0",
"guzzlehttp/guzzle": "^7.2",
"ext-json": "*"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"php-vcr/php-vcr": "^1.5.2",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.0",
"symfony/var-dumper": "^4.2",
"vlucas/phpdotenv": "^2.5"
Expand All @@ -52,7 +57,9 @@
"@install-codestandards"
],
"test": "./vendor/bin/phpunit --colors=always",
"lint": "./vendor/bin/phpcs --warning-severity=6 --runtime-set testVersion 5.6-"
"lint": "./vendor/bin/phpcs --warning-severity=6 --runtime-set testVersion 5.6-",
"analyse": "./vendor/bin/phpstan analyse",
"analyse-ci": "./vendor/bin/phpstan analyse --error-format github > phpstan.json"
},
"config": {
"sort-packages": true,
Expand Down
Empty file added phpstan-baseline.neon
Empty file.
14 changes: 14 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
includes:
- phpstan-baseline.neon

parameters:
paths:
- src
- tests

level: 6

excludePaths:
- ./*/*/FileToBeExcluded.php

checkMissingIterableValueType: false
4 changes: 3 additions & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public function partner()

/**
* @throws XCoverException
*
* @return void
*/
public function validateCredentials()
{
Expand All @@ -127,4 +129,4 @@ public function getBasePath()

return $basePath . '/' . rtrim($this->apiPrefix(), '/');
}
}
}
11 changes: 6 additions & 5 deletions src/Exceptions/ResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

namespace XCoverClient\Exceptions;

use Psr\Http\Message\ResponseInterface;
use XCoverClient\Response;

class ResponseException extends XCoverException
{
/**
* @var Response The response that threw the exception.
* @var ResponseInterface The response that threw the exception.
*/
protected $response;
protected ResponseInterface $response;

/**
* Creates a ResponseException.
*
* @param Response $response - The response that generated this exception
* @param ResponseInterface $response - The response that generated this exception
*/
public function __construct(Response $response)
public function __construct(ResponseInterface $response)
{
$this->response = $response;

Expand Down Expand Up @@ -52,7 +53,7 @@ protected function getFromResponse($key, $default = null)
/**
* Response getter
*
* @return Response
* @return ResponseInterface
*/
public function getResponse()
{
Expand Down
20 changes: 17 additions & 3 deletions src/Middleware/AuthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,24 @@
*/
class AuthMiddleware
{
/**
* @var string
*/
const SIGNATURE_ALGORITHM = 'sha512';

/**
* @var string
*/
private $apiKey;

/**
* @var string
*/
private $apiSecret;

/**
* @var array
*/
protected $configs = [];

/**
Expand Down Expand Up @@ -85,11 +99,11 @@ private function signatureTemplate()
/**
* Make the signature string
*
* @param $signatureContentString
* @param string $signatureContentString
*
* @return string
*/
private function makeSignatureString($signatureContentString)
private function makeSignatureString(string $signatureContentString)
{
return base64_encode(
hash_hmac(
Expand All @@ -114,4 +128,4 @@ private function makeSignatureContentString(array $parts)
'date: ' . $parts['date'],
]);
}
}
}
10 changes: 8 additions & 2 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Response extends BaseResponse
*/
protected $json;

/**
* @return array|mixed|null
*/
public function json()
{
if ($this->json) {
Expand All @@ -32,8 +35,11 @@ public function json()
return null;
}

public function isJsonResponse()
/**
* @return bool
*/
public function isJsonResponse(): bool
{
return false !== strpos($this->getHeaderLine('Content-Type'), 'application/json');
}
}
}
Loading

0 comments on commit 87cd59b

Please sign in to comment.