/
a11igator
/
gigachat-php-sdk
Обзор
Документация
Войти
/
a11igator
/
gigachat-php-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Type/AccessToken.php
44 строки
994 B
Eduard Gaynutdinov
init commit
03 фев 2024, 02:14
03 фев 2024, 02:14
0bf6651
Код
Авторство
О чём код?
<?php declare(strict_types=1); namespace Edvardpotter\GigaChat\Type; class AccessToken implements ArrayConverterInterface { private string $accessToken; private \DateTimeImmutable $expiresAt; public function __construct( string $accessToken, \DateTimeImmutable $expiresAt ) { $this->accessToken = $accessToken; $this->expiresAt = $expiresAt; } public function getAccessToken(): string { return $this->accessToken; } public function getExpiresAt(): \DateTimeImmutable { return $this->expiresAt; } public function isExpired(): bool { return new \DateTime() >= $this->expiresAt; } public static function createFromArray(array $array): self { $expireAtDatetime = new \DateTimeImmutable('@' . floor($array['expires_at'] / 1000)); return new AccessToken( $array['access_token'], $expireAtDatetime ); } }