first commit

This commit is contained in:
2025-09-12 15:23:08 +08:00
commit a80c237bbb
117 changed files with 15628 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Lib\Jwt;
use App\Interface\JwtInterface;
use Hyperf\Collection\Arr;
use Hyperf\Contract\ConfigInterface;
use function Hyperf\Support\make;
final class JwtFactory
{
public function __construct(
private readonly ConfigInterface $config,
) {}
/**
* @param string $name
* @return JwtInterface
*/
public function get(string $name = 'default'): JwtInterface
{
return make(Jwt::class, [
'config' => $this->getConfig($name),
]);
}
/**
* 获取场景配置
* @param string $scene
* @return array
*/
public function getConfig(string $scene): array
{
if ($scene === 'default') {
return $this->config->get($this->getConfigKey());
}
return Arr::merge(
$this->config->get($this->getConfigKey()),
$this->config->get($this->getConfigKey($scene), [])
);
}
/**
* @param string $name
* @return string
*/
private function getConfigKey(string $name = 'default'): string
{
return 'jwt.' . $name;
}
}