YoastSEO_Vendor\League\OAuth2\Client\Token
AccessToken::__construct() public Yoast 1.0
Constructs an access token.
{} Это метод класса: AccessToken{}
Хуков нет.
Возвращает
null
. Ничего.
Использование
$AccessToken = new AccessToken(); $AccessToken->__construct( $options );
- $options(массив)
- An array of options returned by the service provider
php in the access token request. The `access_token` option is required.
Код AccessToken::__construct() AccessToken:: construct Yoast 16.1.1
public function __construct(array $options = [])
{
if (empty($options['access_token'])) {
throw new \InvalidArgumentException('Required option not passed: "access_token"');
}
$this->accessToken = $options['access_token'];
if (!empty($options['resource_owner_id'])) {
$this->resourceOwnerId = $options['resource_owner_id'];
}
if (!empty($options['refresh_token'])) {
$this->refreshToken = $options['refresh_token'];
}
// We need to know when the token expires. Show preference to
// 'expires_in' since it is defined in RFC6749 Section 5.1.
// Defer to 'expires' if it is provided instead.
if (isset($options['expires_in'])) {
if (!\is_numeric($options['expires_in'])) {
throw new \InvalidArgumentException('expires_in value must be an integer');
}
$this->expires = $options['expires_in'] != 0 ? \time() + $options['expires_in'] : 0;
} elseif (!empty($options['expires'])) {
// Some providers supply the seconds until expiration rather than
// the exact timestamp. Take a best guess at which we received.
$expires = $options['expires'];
if (!$this->isExpirationTimestamp($expires)) {
$expires += \time();
}
$this->expires = $expires;
}
// Capture any additional values that might exist in the token but are
// not part of the standard response. Vendors will sometimes pass
// additional user data this way.
$this->values = \array_diff_key($options, \array_flip(['access_token', 'resource_owner_id', 'refresh_token', 'expires_in', 'expires']));
}