php 8
This commit is contained in:
@@ -28,9 +28,9 @@ class ApiTransport implements TransportInterface
|
|||||||
private string $_clientSecret = '';
|
private string $_clientSecret = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string | null
|
||||||
*/
|
*/
|
||||||
private string $_accessToken = '';
|
private ?string $_accessToken = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Guzzle
|
* @var Guzzle
|
||||||
@@ -153,20 +153,21 @@ class ApiTransport implements TransportInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setToken()
|
private function setToken(): void
|
||||||
{
|
{
|
||||||
if ($this->_cache !== null) {
|
if ($this->_cache !== null) {
|
||||||
$this->_accessToken = $this->_cache->get('access_token');
|
$token = $this->_cache->get('access_token');
|
||||||
} else {
|
|
||||||
if ($this->_logger !== null) {
|
if ($token) {
|
||||||
$this->_logger->notice('No cache available for client. Providing a cache interface can improve client response times.');
|
$this->_accessToken = $token;
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$this->_logger?->notice('No cache available for client. Providing a cache interface can improve client response times.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->_accessToken)) {
|
$this->refreshToken();
|
||||||
$this->refreshToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function refreshToken(): void
|
private function refreshToken(): void
|
||||||
@@ -185,9 +186,9 @@ class ApiTransport implements TransportInterface
|
|||||||
$body = $result->getBody()->getContents();
|
$body = $result->getBody()->getContents();
|
||||||
$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
|
$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
|
||||||
$this->_accessToken = $data->access_token;
|
$this->_accessToken = $data['access_token'];
|
||||||
|
|
||||||
$this->_cache?->set('access_token', $this->_accessToken, $data->expires_in);
|
$this->_cache?->set('access_token', $this->_accessToken, $data['expires_in']);
|
||||||
|
|
||||||
} catch (\JsonException | ServerException | RequestException | GuzzleException $exception) {
|
} catch (\JsonException | ServerException | RequestException | GuzzleException $exception) {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user