Skip to content

Commit ea20170

Browse files
committed
Lower PHPStan level
Keep old behaviour and the code simpler, no need to get overly complex just to please PHPStan's max level
1 parent 1ad7ca9 commit ea20170

File tree

4 files changed

+9
-66
lines changed

4 files changed

+9
-66
lines changed

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ parameters:
22
paths:
33
- src
44

5-
level: max
5+
level: 8
66

77
reportUnmatchedIgnoredErrors: true

src/AutoRefreshOAuth2TokenPlugin.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class AutoRefreshOAuth2TokenPlugin implements Plugin
2424
protected RefreshToken $refreshTokenGrant;
2525

2626
/**
27-
* @var Options
27+
* @var array<string, mixed>
2828
*/
29-
protected Options $options;
29+
protected array $options;
3030

3131
/**
3232
* @var array<string, mixed>
@@ -47,9 +47,13 @@ public function __construct(
4747
array $options = [],
4848
array $refreshTokenOptions = []
4949
) {
50+
$defaults = [
51+
'threshold' => 300, // 5 minutes
52+
];
53+
5054
$this->token = $token;
5155
$this->refreshTokenGrant = $refreshTokenGrant;
52-
$this->options = new Options($options);
56+
$this->options = array_replace_recursive($defaults, $options);
5357
$this->refreshTokenOptions = $refreshTokenOptions;
5458
}
5559

@@ -58,7 +62,7 @@ public function __construct(
5862
*/
5963
protected function maybeRefreshToken(): void
6064
{
61-
$expires = $this->token->getExpires() - $this->options->threshold;
65+
$expires = $this->token->getExpires() - (int) $this->options['threshold'];
6266

6367
if (time() >= $expires) {
6468
$this->token = $this->refreshTokenGrant->requestAccessToken(

src/Options.php

Lines changed: 0 additions & 40 deletions
This file was deleted.

tests/OptionsTest.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)