/
githubmirror
/
ydb-php-sdk
Обзор
Документация
Войти
/
githubmirror
/
ydb-php-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Auth/ReadTokenFromFile.php
38 строк
930 B
Илья
Rename to ReadTokenFromFile
30 авг 2023, 10:48
30 авг 2023, 10:48
6901325
Код
Авторство
О чём код?
<?php namespace YdbPlatform\Ydb\Auth; class ReadTokenFromFile extends Auth { protected $fileName; protected $readInterval; /** * @param string $fileName * @param int $readInterval */ public function __construct(string $fileName = "token.txt", int $readInterval = 60) { if(file_get_contents($fileName)===false){ throw new \Exception("Error reading the file '$fileName'"); } $this->fileName = $fileName; $this->readInterval = $readInterval; } public function getTokenInfo(): TokenInfo { $token = file_get_contents($this->fileName); if($token===false){ throw new \Exception("Error reading the file '$this->fileName'"); } $token = trim($token); return new TokenInfo($token, $this->readInterval, 1); } public function getName(): string { return "from file"; } }