Conditions | 2 |
Paths | 2 |
Total Lines | 19 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | 8 | public static function get( |
|
20 | string $refreshUrl, |
||
21 | Credentials $credentials, |
||
22 | Options $options, |
||
23 | ): AccessToken { |
||
24 | 8 | $cacheKey = $options->cacheKey ?? static::generateCacheKey($refreshUrl); |
|
25 | |||
26 | 8 | $accessToken = Cache::store($options->cacheDriver)->get($cacheKey); |
|
27 | |||
28 | 8 | if ($accessToken) { |
|
29 | 2 | return $accessToken; |
|
30 | } |
||
31 | |||
32 | 8 | $accessToken = app(RefreshToken::class)(...func_get_args()); |
|
33 | 8 | $ttl = $accessToken->getExpiresIn(); |
|
34 | |||
35 | 8 | Cache::store($options->cacheDriver)->put($cacheKey, $accessToken, $ttl); |
|
36 | |||
37 | 8 | return $accessToken; |
|
38 | } |
||
40 |