Files
webman-buildadmin-mall/app/common/facade/Token.php
2026-03-18 17:19:03 +08:00

61 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace app\common\facade;
use app\common\library\Token as TokenLibrary;
/**
* Token 门面类Webman 等价实现,替代 ThinkPHP Facade
* @see TokenLibrary
* @method static array get(string $token)
* @method static bool set(string $token, string $type, int $userId, ?int $expire = null)
* @method static bool check(string $token, string $type, int $userId)
* @method static bool delete(string $token)
* @method static bool clear(string $type, int $userId)
* @method static void tokenExpirationCheck(array $token)
*/
class Token
{
private static ?TokenLibrary $instance = null;
private static function getInstance(): TokenLibrary
{
if (self::$instance === null) {
self::$instance = new TokenLibrary();
}
return self::$instance;
}
public static function get(string $token): array
{
return self::getInstance()->get($token);
}
public static function set(string $token, string $type, int $userId, ?int $expire = null): bool
{
return self::getInstance()->set($token, $type, $userId, $expire);
}
public static function check(string $token, string $type, int $userId): bool
{
return self::getInstance()->check($token, $type, $userId);
}
public static function delete(string $token): bool
{
return self::getInstance()->delete($token);
}
public static function clear(string $type, int $userId): bool
{
return self::getInstance()->clear($type, $userId);
}
public static function tokenExpirationCheck(array $token): void
{
self::getInstance()->tokenExpirationCheck($token);
}
}