/
githubmirror
/
ydb-php-sdk
Обзор
Документация
Войти
/
githubmirror
/
ydb-php-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Auth/TokenInfo.php
45 строк
785 B
Илья
Create private refresh ratio token parametr
22 авг 2023, 12:02
22 авг 2023, 12:02
5159a4d
Код
Авторство
О чём код?
<?php namespace YdbPlatform\Ydb\Auth; class TokenInfo { /** * @var string */ protected $token; /** * @var int */ protected $expiresAt; private $refreshAt; public function __construct(string $token, int $expiresAt, float $refreshRatio = 0.1) { $this->token = $token; $this->expiresAt = $expiresAt; $this->refreshAt = time() + round($refreshRatio*($this->expiresAt-time()),0); } /** * @return int */ public function getExpiresAt(): int { return $this->expiresAt; } /** * @return string */ public function getToken(): string { return $this->token; } public function getRefreshAt(): int { return $this->refreshAt; } }