Skip to content

Commit d295915

Browse files
committed
integrated laravel/pint as dev requirement for PHP style fixing
dropped PHP 8.0 support
1 parent ccdb4b2 commit d295915

File tree

17 files changed

+76
-38
lines changed

17 files changed

+76
-38
lines changed

.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
~*
2-
vendor
1+
/vendor
2+
/samples/client_tokens.json
3+
/playground/*
34
composer.lock
4-
5-
samples/client_tokens.json
6-
playground/*
5+
.pint.cache.json

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## [0.4.x (Unreleased)](https://github.com/onlime/bexio-api-client/compare/0.3.1...main)
44

55
- Added Bexio company profile endpoint request methods to `Other` resource.
6+
- Drop PHP 8.0 support
7+
- Integrated laravel/pint as dev requirement for PHP style fixing
68

79
## [0.4.1 (2022-03-24)](https://github.com/onlime/bexio-api-client/compare/0.4.0...0.4.1)
810

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^8.0",
23+
"php": "^8.1",
2424
"ext-json": "*",
25-
"jumbojett/openid-connect-php": "^0.9.5",
26-
"guzzlehttp/guzzle": "^7.4"
25+
"jumbojett/openid-connect-php": "^0.9.10",
26+
"guzzlehttp/guzzle": "^7.5"
27+
},
28+
"require-dev": {
29+
"laravel/pint": "^1.2"
2730
},
2831
"suggest": {
2932
"onlime/laravel-bexio-api-client": "To use Laravel HTTP Client instead of Guzzle"

pint.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"preset": "laravel",
3+
"rules": {
4+
"braces": false,
5+
"blank_line_before_statement": false,
6+
"class_definition": false,
7+
"binary_operator_spaces": false,
8+
"concat_space": false,
9+
"no_unused_imports": false,
10+
"Laravel/laravel_phpdoc_alignment": false,
11+
"Laravel/laravel_phpdoc_separation": false,
12+
"modernize_strpos": true
13+
},
14+
"exclude": [
15+
"node_modules"
16+
],
17+
"cache-file": ".pint.cache.json"
18+
}

samples/sample.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
require_once '../vendor/autoload.php';
34

45
use Bexio\Client;

src/Bexio/AbstractClient.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
<?php
2+
23
namespace Bexio;
34

45
use Jumbojett\OpenIDConnectClient;
56

67
abstract class AbstractClient
78
{
89
const PROVIDER_URL = 'https://idp.bexio.com';
10+
911
const API_URL = 'https://api.bexio.com';
12+
1013
const API_DEFAULT_VERSION = '2.0';
1114

1215
const METHOD_GET = 'GET';
16+
1317
const METHOD_POST = 'POST';
18+
1419
const METHOD_PUT = 'PUT';
20+
1521
const METHOD_DELETE = 'DELETE';
22+
1623
const METHOD_PATCH = 'PATCH';
1724

1825
private ?string $accessToken = null;
26+
1927
private ?string $refreshToken = null;
2028

2129
public function __construct(
2230
public string $clientId,
2331
public string $clientSecret
24-
) {}
32+
) {
33+
}
2534

2635
public function setAccessToken(string $accessToken)
2736
{
@@ -47,13 +56,13 @@ public function persistTokens(string $tokensFile): bool
4756
{
4857
return false !== file_put_contents($tokensFile, json_encode([
4958
'accessToken' => $this->getAccessToken(),
50-
'refreshToken' => $this->getRefreshToken()
59+
'refreshToken' => $this->getRefreshToken(),
5160
]));
5261
}
5362

5463
public function loadTokens(string $tokensFile)
5564
{
56-
if (!file_exists($tokensFile)) {
65+
if (! file_exists($tokensFile)) {
5766
throw new \Exception('Tokens file not found: ' . $tokensFile);
5867
}
5968
$tokens = json_decode(file_get_contents($tokensFile));
@@ -81,7 +90,7 @@ public function getOpenIDConnectClient(): OpenIDConnectClient
8190

8291
public function authenticate(string|array $scopes, string $redirectUrl)
8392
{
84-
if (!is_array($scopes)) {
93+
if (! is_array($scopes)) {
8594
$scopes = explode(' ', $scopes);
8695
}
8796

@@ -96,7 +105,7 @@ public function authenticate(string|array $scopes, string $redirectUrl)
96105

97106
public function isAccessTokenExpired($gracePeriod = 30): bool
98107
{
99-
if (!$this->accessToken) {
108+
if (! $this->accessToken) {
100109
return true;
101110
}
102111
$payload = $this->getOpenIDConnectClient()->getAccessTokenPayload();
@@ -118,13 +127,17 @@ public function getFullApiUrl(string $path = '', array $query = []): string
118127
return implode('/', array_filter([
119128
self::API_URL,
120129
1 === preg_match('/\d\.\d\//', $path) ? '' : self::API_DEFAULT_VERSION,
121-
empty($query) ? $path : $path . '?' . http_build_query($query)
130+
empty($query) ? $path : $path . '?' . http_build_query($query),
122131
]));
123132
}
124133

125134
abstract public function get(string $path, array $queryParams = []);
135+
126136
abstract public function post(string $path, array $data = [], array $queryParams = []);
137+
127138
abstract public function put(string $path, array $data = [], array $queryParams = []);
139+
128140
abstract public function delete(string $path, array $data = [], array $queryParams = []);
141+
129142
abstract public function patch(string $path, array $data = [], array $queryParams = []);
130143
}

src/Bexio/Bexio.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
2+
23
namespace Bexio;
34

45
class Bexio
56
{
67
public function __construct(
78
protected AbstractClient $client
8-
) {}
9-
}
9+
) {
10+
}
11+
}

src/Bexio/Client.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
2+
23
namespace Bexio;
34

45
use Bexio\Exception\BexioClientException;
5-
use GuzzleHttp\Exception\ClientException;
66
use GuzzleHttp\Client as GuzzleClient;
7+
use GuzzleHttp\Exception\ClientException;
78

89
class Client extends AbstractClient
910
{
@@ -46,11 +47,11 @@ protected function request(
4647
'allow_redirects' => false,
4748
];
4849

49-
if (!empty($queryParams)) {
50+
if (! empty($queryParams)) {
5051
$options['query'] = $queryParams;
5152
}
5253

53-
if (!empty($data) && self::METHOD_GET !== $method) {
54+
if (! empty($data) && self::METHOD_GET !== $method) {
5455
$options['json'] = $data;
5556
}
5657

src/Bexio/Exception/BexioClientException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Bexio\Exception;
34

45
use Exception;

src/Bexio/Resource/AbstractDocumentPositions.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
2+
23
namespace Bexio\Resource;
34

45
use Bexio\Bexio;
56

67
/**
78
* Class Invoice
8-
* @package Bexio\Resource
99
*/
1010
abstract class AbstractDocumentPositions extends Bexio
1111
{
@@ -73,7 +73,6 @@ public function deleteDefaultPosition(int $documentId, int $itemId)
7373
return $this->client->delete($this->documentType . "/$documentId/kb_position_custom/$itemId");
7474
}
7575

76-
7776
/**
7877
* @param int $documentId
7978
* @param array $params
@@ -136,7 +135,6 @@ public function deleteItemPosition(int $documentId, int $itemId)
136135
return $this->client->delete($this->documentType . "/$documentId/kb_position_article/$itemId");
137136
}
138137

139-
140138
/**
141139
* @param int $documentId
142140
* @param array $params
@@ -198,4 +196,4 @@ public function deleteDiscountPosition(int $documentId, int $itemId)
198196
{
199197
return $this->client->delete($this->documentType . "/$documentId/kb_position_discount/$itemId");
200198
}
201-
}
199+
}

0 commit comments

Comments
 (0)