save
This commit is contained in:
parent
357735ee22
commit
ebe8902831
@ -22,3 +22,6 @@ aesiv=""
|
||||
dbuser=""
|
||||
dbpass=""
|
||||
#数据库用户名和密码
|
||||
|
||||
redis_password=""
|
||||
#redis密码
|
52
app/controller/Account.php
Normal file
52
app/controller/Account.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Redis;
|
||||
use support\Db;
|
||||
|
||||
class Account
|
||||
{
|
||||
public function loginCallback(Request $request)
|
||||
{
|
||||
$rd=$request->input('rd','null');
|
||||
$sum=$request->input('sum','null');
|
||||
$uid=$request->input('id','null');
|
||||
if($rd=='null'||$sum=='null'||$sum!=md5($rd.$uid.getenv('aeskey'))){
|
||||
return view('404');
|
||||
}
|
||||
$session = $request->session();
|
||||
$session->set('ACCOUNT_CALLBACK_rd', $rd);
|
||||
$session->set('ACCOUNT', $uid);
|
||||
$user = Db::table('User')->where('ID', $uid)->first();
|
||||
$requireFields = array();
|
||||
$i=0;
|
||||
foreach($user as $key=>$value){
|
||||
if(in_array($key, ['name','sex','email','phone','address','sfz','birthday','avatar','realname'])&&($value==null||$value==''||$value=='null')){
|
||||
array_push($requireFields,$key);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if($i>0){
|
||||
return view('account/extend', ['userid'=>$user->ID,'username'=>$user->name,'requireFields'=>$requireFields]);
|
||||
}else{
|
||||
$session->set('ACCOUNT_ve', 1);
|
||||
$session->forget(['ACCOUNT_CALLBACK_rd']);
|
||||
return redirect($rd);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function view(Request $request)
|
||||
{
|
||||
return view('index/view', ['name' => 'webman']);
|
||||
}
|
||||
|
||||
public function json(Request $request)
|
||||
{
|
||||
return json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,8 @@ class LayAuth
|
||||
}
|
||||
$app=$appquery->first();
|
||||
$provider= Db::table('Provider')->where('ID', $app->provider)->first();
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider]);
|
||||
$redirecturl='https://'.getenv('weburl').'/auth/lay/'.$appid.'/callback';
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'redirecturl'=>$redirecturl]);
|
||||
|
||||
}
|
||||
|
||||
@ -30,11 +31,12 @@ class LayAuth
|
||||
}
|
||||
$app=$appquery->first();
|
||||
$provider= Db::table('Provider')->where('ID', $app->provider)->first();
|
||||
$redirecturl='https://'.getenv('weburl').'/auth/lay/'.$appid.'/callback';
|
||||
switch ($gateway) {
|
||||
case "qywx":
|
||||
$code = $request->input('code','null');
|
||||
if($code=='null'){
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'登陆信息无效']);
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'登陆信息无效','redirecturl'=>$redirecturl]);
|
||||
}
|
||||
$tokenfile=base_path().'/token/qywx/innerQYWX.token';
|
||||
if(file_exists($tokenfile)){
|
||||
@ -59,7 +61,7 @@ class LayAuth
|
||||
}
|
||||
$lookup= Http::get('https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token='.$fulltoken.'&code='.$code)->json();
|
||||
if($lookup->errcode!=0){
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'登陆信息无效']);
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'登陆信息无效','redirecturl'=>$redirecturl]);
|
||||
}else{
|
||||
$userid=$lookup->userid;
|
||||
$userinfo=Http::get('https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token='.$fulltoken.'&userid='.$userid)->json();
|
||||
@ -74,10 +76,10 @@ class LayAuth
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'验证方式无效或不存在']);
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'验证方式无效或不存在','redirecturl'=>$redirecturl]);
|
||||
}
|
||||
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'验证方式无效或不存在']);
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'验证方式无效或不存在','redirecturl'=>$redirecturl]);
|
||||
}
|
||||
|
||||
public function check(Request $request,$appid)
|
||||
|
@ -25,9 +25,76 @@ class OAuth
|
||||
if($redirect=='null'){
|
||||
$redirect=$app->redirect;
|
||||
}
|
||||
return redirect($redirect.'?code=123456&state='.$request->get('state',''));
|
||||
$scope=$request->get('scope','openid');
|
||||
$scope=explode("+",$scope);
|
||||
$allow_scope=json_decode($app->scope,true);
|
||||
$scope=array_intersect($scope,$allow_scope);
|
||||
$session = $request->session();
|
||||
$session->set($appid.'_oauth_redirect', $redirect);
|
||||
$session->set($appid.'_oauth_scope', $scope);
|
||||
|
||||
$redirecturl='https://'.getenv('weburl').'/auth/oauth/back/'.$appid;
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'redirecturl'=>$redirecturl]);
|
||||
|
||||
#return redirect($redirect.'?code=123456&state='.$request->get('state',''));
|
||||
#return view('auth', ['app'=>$app,'provider'=>$provider]);
|
||||
}
|
||||
public function callback(Request $request,$appid,$gateway)
|
||||
{
|
||||
$appquery= Db::table('App')->where('oauthid', $appid);
|
||||
if($appquery->doesntExist()){
|
||||
return view('404');
|
||||
}
|
||||
$app=$appquery->first();
|
||||
$provider= Db::table('Provider')->where('ID', $app->provider)->first();
|
||||
$redirecturl='https://'.getenv('weburl').'/auth/oauth/back/'.$appid;
|
||||
|
||||
switch ($gateway) {
|
||||
case "qywx":
|
||||
$code = $request->input('code','null');
|
||||
if($code=='null'){
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'登陆信息无效','redirecturl'=>$redirecturl]);
|
||||
}
|
||||
$tokenfile=base_path().'/token/qywx/innerQYWX.token';
|
||||
if(file_exists($tokenfile)){
|
||||
$tokencontent=json_decode(file_get_contents($tokenfile));
|
||||
$fulltoken=$tokencontent->token;
|
||||
$ddl=$tokencontent->ddl;
|
||||
if($ddl-time()<180){
|
||||
$reapply=true;
|
||||
}else{
|
||||
$reapply=false;
|
||||
}
|
||||
}else{
|
||||
$reapply=true;
|
||||
}
|
||||
if($reapply==true){
|
||||
$apply=$response = Http::get('https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid='.getenv('appid').'&corpsecret='.getenv('token'))->json();
|
||||
$fulltoken=$apply->access_token;
|
||||
$ddl=time()+$apply->expires_in;
|
||||
$file=fopen($tokenfile,"w");
|
||||
fwrite($file, json_encode(array('token'=>$fulltoken,'ddl'=>$ddl)));
|
||||
fclose($file);
|
||||
}
|
||||
$lookup= Http::get('https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token='.$fulltoken.'&code='.$code)->json();
|
||||
if($lookup->errcode!=0){
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'登陆信息无效','redirecturl'=>$redirecturl]);
|
||||
}
|
||||
$userid=$lookup->userid;
|
||||
$userinfo=Http::get('https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token='.$fulltoken.'&userid='.$userid)->json();
|
||||
$username=$userinfo->name;
|
||||
$userposition=$userinfo->position;
|
||||
$WT=json_encode(['id'=>$userid,'name'=>$username,'position'=>$userposition,'time'=>time()]);
|
||||
$key = getenv('aeskey');
|
||||
$iv = getenv('aesiv');
|
||||
$WT = encryptAES($WT, $key, $iv);
|
||||
$dest=$app->redirect;
|
||||
return view('success', ['app'=>$app,'provider'=>$provider,'dest'=>$dest,'userinfo'=>$userinfo])->cookie('WT', $WT,time()+9600,'/','.laysense.cn');
|
||||
break;
|
||||
default:
|
||||
return view('auth', ['app'=>$app,'provider'=>$provider,'special'=>'验证方式无效或不存在','redirecturl'=>$redirecturl]);
|
||||
}
|
||||
}
|
||||
|
||||
public function configfile(Request $request)
|
||||
{
|
||||
@ -40,11 +107,11 @@ class OAuth
|
||||
"response_types_supported" => ["code"],
|
||||
"subject_types_supported" => ["public"],
|
||||
"id_token_signing_alg_values_supported" => ["RS256"],
|
||||
"scopes_supported" => ["openid", "profile", "email", "phone"],
|
||||
"scopes_supported" => ["openid", "profile", "email", "phone", "avatar","basic","detail","everything"],
|
||||
"token_endpoint_auth_methods_supported" => ["client_secret_basic"],
|
||||
"claims_supported" => ["sub", "iss", "name", "email", "phone"],
|
||||
"claims_supported" => ["sub", "iss", "name", "email", "phone","LaysenseRole","avatar","phone","address","age","sex","birthday"],
|
||||
"code_challenge_methods_supported" => ["plain", "S256"],
|
||||
"grant_types_supported" => ["authorization_code", "refresh_token"],
|
||||
"grant_types_supported" => ["authorization_code"],
|
||||
]);
|
||||
}
|
||||
|
||||
@ -58,7 +125,6 @@ class OAuth
|
||||
'iat' => time(),
|
||||
'nbf' => time()+7200,
|
||||
'exp' => time()+7200,
|
||||
'LaysenseRole' => 'Member',
|
||||
];
|
||||
$jwt = JWT::encode($payload, $key, 'HS256');
|
||||
|
||||
@ -78,6 +144,7 @@ class OAuth
|
||||
{
|
||||
return json([
|
||||
"sub" => 'ywnsya',
|
||||
'iss' => 'https://auth.laysense.cn/',
|
||||
"name" => 'LaySense',
|
||||
"email" => 'ywnsya@126.com',
|
||||
"phone" => '18018526850',
|
||||
|
151
app/controller/QywxOauth.php
Normal file
151
app/controller/QywxOauth.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use support\Request;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use support\Redis;
|
||||
use support\Db;
|
||||
use tekintian\TekinQR;
|
||||
use yzh52521\EasyHttp\Http;
|
||||
use yzh52521\EasyHttp\Response;
|
||||
use yzh52521\EasyHttp\RequestException;
|
||||
|
||||
class QywxOauth
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$rd=$request->input('rd','null');
|
||||
$sum=$request->input('sum','null');
|
||||
|
||||
if($rd=='null'||$sum=='null'||$sum!=md5($rd.getenv('aeskey'))){
|
||||
return view('404');
|
||||
}
|
||||
$session = $request->session();
|
||||
$session->set('QYWX_OAUTH_rd', $rd);
|
||||
$app=$request->header('X-Requested-With','null');
|
||||
if($app=='com.tencent.wework'){
|
||||
$redirecturl='https://'.getenv('weburl').'/qywxoauth/info';
|
||||
$url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=".getenv('appid')."&redirect_uri=".$redirecturl."&response_type=code&scope=snsapi_privateinfo&state=STATE&agentid=".getenv('agentid')."#wechat_redirect";
|
||||
return redirect($url);
|
||||
}
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
Redis::set($uuid, 'null');
|
||||
Redis::expire($uuid, 300);
|
||||
|
||||
$redirecturl='https://'.getenv('weburl').'/qywxoauth/answer/'.$uuid;
|
||||
$url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=".getenv('appid')."&redirect_uri=".$redirecturl."&response_type=code&scope=snsapi_privateinfo&state=STATE&agentid=".getenv('agentid')."#wechat_redirect";
|
||||
$qr = TekinQR::getQRImg($url, 10, base_path().'/public/qywx.png', 1);
|
||||
|
||||
return view('qywx/wait', ['url'=>$url,'uuid'=>$uuid,'qr'=>$qr,'to'=>'https://'.getenv('weburl').'/qywxoauth/info']);
|
||||
}
|
||||
|
||||
public function answer(Request $request,$uuid)
|
||||
{
|
||||
if($uuid=='null'||!Uuid::isValid($uuid)){
|
||||
return view('404');
|
||||
}
|
||||
if(!Redis::exists($uuid)){
|
||||
return view('qywx/expire');
|
||||
}
|
||||
$code=$request->input('code','null');
|
||||
if($code=='null'){
|
||||
return view('404');
|
||||
}
|
||||
Redis::set($uuid, $code);
|
||||
Redis::expire($uuid, 10);
|
||||
|
||||
return view('qywx/success');
|
||||
}
|
||||
|
||||
public function ask(Request $request,$uuid)
|
||||
{
|
||||
if($uuid=='null'||!Uuid::isValid($uuid)){
|
||||
return json(['code' => 501, 'msg' => 'invaild uuid']);
|
||||
}
|
||||
if(!Redis::exists($uuid)){
|
||||
return json(['code' => 500, 'msg' => 'UUID expired']);
|
||||
}
|
||||
for($i=0;$i<150;$i++){
|
||||
if(!Redis::exists($uuid)){
|
||||
return json(['code' => 500, 'msg' => 'UUID expired']);
|
||||
}
|
||||
if(Redis::get($uuid)!='null'){
|
||||
return json(['code' => 200, 'msg' => 'ok','rcode'=>Redis::get($uuid)]);
|
||||
break;
|
||||
}
|
||||
sleep(2);
|
||||
}
|
||||
return json(['code' => 503, 'msg' => 'TimeOut']);
|
||||
/**
|
||||
$code=Redis::get($uuid);
|
||||
if($code=='null'){
|
||||
return json(['code' => 201, 'msg' => 'wait for answer']);
|
||||
}
|
||||
return json(['code' => 200, 'msg' => 'ok','code'=>$code]);
|
||||
**/
|
||||
}
|
||||
public function info(Request $request)
|
||||
{
|
||||
$code=$request->input('code','null');
|
||||
if($code=='null'){
|
||||
return view('404');
|
||||
}
|
||||
$tokenfile=base_path().'/token/qywx/innerQYWX.token';
|
||||
if(file_exists($tokenfile)){
|
||||
$tokencontent=json_decode(file_get_contents($tokenfile));
|
||||
$fulltoken=$tokencontent->token;
|
||||
$ddl=$tokencontent->ddl;
|
||||
if($ddl-time()<180){
|
||||
$reapply=true;
|
||||
}else{
|
||||
$reapply=false;
|
||||
}
|
||||
}else{
|
||||
$reapply=true;
|
||||
}
|
||||
if($reapply==true){
|
||||
$apply=$response = Http::get('https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid='.getenv('appid').'&corpsecret='.getenv('token'))->json();
|
||||
$fulltoken=$apply->access_token;
|
||||
$ddl=time()+$apply->expires_in;
|
||||
$file=fopen($tokenfile,"w");
|
||||
fwrite($file, json_encode(array('token'=>$fulltoken,'ddl'=>$ddl)));
|
||||
fclose($file);
|
||||
}
|
||||
$lookup= Http::get('https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token='.$fulltoken.'&code='.$code)->json();
|
||||
if($lookup->errcode!=0){
|
||||
return view('404');
|
||||
}
|
||||
$userid=$lookup->userid;
|
||||
$usertoken=$lookup->user_ticket;
|
||||
$userinfo=Http::asJson()->post('https://qyapi.weixin.qq.com/cgi-bin/auth/getuserdetail?access_token='.$fulltoken,['user_ticket' => "$usertoken"])->json();
|
||||
$userbasic=Http::get('https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token='.$fulltoken.'&userid='.$userid)->json();
|
||||
if($userinfo->errcode!=0 || $userbasic->errcode!=0){
|
||||
return view('404');
|
||||
}
|
||||
$userinfo->name=$userbasic->name;
|
||||
$userinfo->postion=$userbasic->position;
|
||||
$userinfo->id=$userinfo->userid;
|
||||
if($userinfo->email==''||$userinfo->biz_mail==''){
|
||||
$mail=$userinfo->email.$userinfo->biz_mail;
|
||||
$userinfo->email=$mail;
|
||||
$userinfo->biz_mail=$mail;
|
||||
}
|
||||
Db::table('User')
|
||||
->updateOrInsert(
|
||||
['ID' => $userid.'@laysense'],
|
||||
['public' => 0,'name' => $userinfo->name,'sex'=>$userinfo->gender,'position' => $userinfo->postion,'avatar' => $userinfo->avatar,'email' => $userinfo->email,'phone' => $userinfo->mobile,'biz_mail'=>$userinfo->biz_mail,'address'=>$userinfo->address,'role'=>1]
|
||||
);
|
||||
$session = $request->session();
|
||||
$rd=$session->get('QYWX_OAUTH_rd','null');
|
||||
if($rd=='null'){
|
||||
return view('404');
|
||||
}
|
||||
$sum=md5($rd.$userid.'@laysense'.getenv('aeskey'));
|
||||
$session->forget(['QYWX_OAUTH_rd']);
|
||||
|
||||
|
||||
return redirect('/account/loginCallback?rd='.$rd.'&sum='.$sum.'&id='.$userid.'@laysense');
|
||||
}
|
||||
|
||||
}
|
211
app/view/account/extend.html
Normal file
211
app/view/account/extend.html
Normal file
@ -0,0 +1,211 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" class="h-full">
|
||||
<head>
|
||||
<!-- Required Meta Tags Always Come First -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="Laysense Auth">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<title>Laysense Auth</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="https://static.laysense.cn/data/file/_4335ce.png?1709117691655">
|
||||
|
||||
<!-- Font -->
|
||||
|
||||
<!-- Theme Check and Update -->
|
||||
<script>
|
||||
const html = document.querySelector('html');
|
||||
const isLightOrAuto = localStorage.getItem('hs_theme') === 'light' || (localStorage.getItem('hs_theme') === 'auto' && !window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
const isDarkOrAuto = localStorage.getItem('hs_theme') === 'dark' || (localStorage.getItem('hs_theme') === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
|
||||
if (isLightOrAuto && html.classList.contains('dark')) html.classList.remove('dark');
|
||||
else if (isDarkOrAuto && html.classList.contains('light')) html.classList.remove('light');
|
||||
else if (isDarkOrAuto && !html.classList.contains('dark')) html.classList.add('dark');
|
||||
else if (isLightOrAuto && !html.classList.contains('light')) html.classList.add('light');
|
||||
</script>
|
||||
|
||||
<!-- CSS HS -->
|
||||
<link rel="stylesheet" href="https://static.laysense.cn/data/file/cdn/preline.css">
|
||||
</head>
|
||||
|
||||
<body class="dark:bg-neutral-900">
|
||||
<!-- ========== MAIN CONTENT ========== -->
|
||||
<main id="content">
|
||||
<div class="max-w-[85rem] px-4 py-10 sm:px-6 lg:px-8 lg:py-14 mx-auto">
|
||||
<div class="max-w-xl mx-auto">
|
||||
<div class="text-center">
|
||||
<h1 class="text-3xl font-bold text-gray-800 sm:text-4xl dark:text-white">
|
||||
<?php echo($username);?>,欢迎来到来笙~!🥳
|
||||
</h1>
|
||||
<p class="mt-1 text-gray-600 dark:text-neutral-400">
|
||||
您还需要补充下述信息,以便我们为您提供更好的服务。您的隐私信息将被严格加密储存,并严格限制第三方应用的读取。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="mt-12">
|
||||
<!-- Form -->
|
||||
<form>
|
||||
<div class="grid gap-4 lg:gap-6">
|
||||
|
||||
<?php
|
||||
foreach($requireFields as $field){
|
||||
switch ($field) {
|
||||
case 'name':
|
||||
echo '<div>
|
||||
<label for="name" class="block mb-2 text-sm text-gray-700 font-medium dark:text-white">用户名</label>
|
||||
<input type="text" id="name" name="name" class="py-3 px-4 block w-full border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600">
|
||||
</div>';
|
||||
break;
|
||||
case 'sex':
|
||||
echo ' <label class="block text-sm text-gray-700 font-medium dark:text-white">性别</label>
|
||||
<div class="grid sm:grid-cols-2 gap-2">
|
||||
<label for="hs-radio-in-form" class="flex p-3 w-full bg-white border border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400">
|
||||
<input type="radio" name="hs-radio-in-form" class="shrink-0 mt-0.5 border-gray-200 rounded-full text-blue-600 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-800" id="hs-radio-in-form">
|
||||
<span class="text-sm text-gray-500 ms-3 dark:text-neutral-400">先生</span>
|
||||
</label>
|
||||
<label for="hs-radio-checked-in-form" class="flex p-3 w-full bg-white border border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400">
|
||||
<input type="radio" name="hs-radio-in-form" class="shrink-0 mt-0.5 border-gray-200 rounded-full text-blue-600 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-800" id="hs-radio-checked-in-form" checked="">
|
||||
<span class="text-sm text-gray-500 ms-3 dark:text-neutral-400">女士</span>
|
||||
</label>
|
||||
</div>';
|
||||
break;
|
||||
case 'email':
|
||||
echo '<div>
|
||||
<label for="email" class="block mb-2 text-sm text-gray-700 font-medium dark:text-white">邮箱</label>
|
||||
<input type="email" name="hs-work-email-hire-us-2" id="hs-work-email-hire-us-2" autocomplete="email" id="email" name="email" class="py-3 px-4 block w-full border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600">
|
||||
</div>';
|
||||
break;
|
||||
case 'phone':
|
||||
echo '<div>
|
||||
<label for="phone" class="block mb-2 text-sm text-gray-700 font-medium dark:text-white">手机号(仅支持中国大陆,无需填写+86)</label>
|
||||
<input type="number" id="phone" name="phone" class="py-3 px-4 block w-full border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600">
|
||||
</div>';
|
||||
break;
|
||||
case 'address':
|
||||
echo '<div>
|
||||
<label for="address" class="block mb-2 text-sm text-gray-700 font-medium dark:text-white">地址(您参与活动的奖品、来笙硬件、来笙活动邀请函可能会邮寄到此地址)</label>
|
||||
<div data-toggle="distpicker" data-autoselect="3" data-province="浙江省" class="grid grid-cols-1 sm:grid-cols-3 gap-4 mb-2">
|
||||
<select name="province" class="py-3 px-4 pe-9 block border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"></select>
|
||||
<select name="city" class="py-3 px-4 pe-9 block border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"></select>
|
||||
<select name="area" class="py-3 px-4 pe-9 block border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600"></select>
|
||||
</div>
|
||||
<input type="text" id="address" name="address" placeholder="详细地址" class="py-3 px-4 block w-full border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600">
|
||||
|
||||
</div>';
|
||||
break;
|
||||
case 'birthday':
|
||||
echo '<div>
|
||||
<label for="birthday" class="block mb-2 text-sm text-gray-700 font-medium dark:text-white">您的生日</label>
|
||||
<input type="date" id="birthday" name="birthday" class="py-3 px-4 block w-full border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600">
|
||||
</div>';
|
||||
break;
|
||||
case 'avatar':
|
||||
echo '<div>
|
||||
<label class="block">
|
||||
<label for="birthday" class="block mb-2 text-sm text-gray-700 font-medium dark:text-white">给您设置一个美美的头像叭</label>
|
||||
<!--span class="sr-only">Choose profile photo</span-->
|
||||
<input type="file" name="avatar" id="avatar" class="block w-full text-sm text-gray-500
|
||||
file:me-4 file:py-2 file:px-4
|
||||
file:rounded-lg file:border-0
|
||||
file:text-sm file:font-semibold
|
||||
file:bg-blue-600 file:text-white
|
||||
hover:file:bg-blue-700
|
||||
file:disabled:opacity-50 file:disabled:pointer-events-none
|
||||
dark:text-neutral-500
|
||||
dark:file:bg-blue-500
|
||||
dark:hover:file:bg-blue-400
|
||||
">
|
||||
</label>
|
||||
<div class="shrink-0 group block">
|
||||
<div class="flex items-center">
|
||||
<img id="avatarpreview" class="inline-block shrink-0 size-[62px] rounded-full" src="/laysenseLogo.jpg" alt="Avatar">
|
||||
<div class="ms-3">
|
||||
<h3 class="font-semibold text-gray-800 dark:text-white">'.$username.'</h3>
|
||||
<p class="text-sm font-medium text-gray-400 dark:text-neutral-500">来笙新用户</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
break;
|
||||
case 'sfz':
|
||||
echo '<div>
|
||||
<label for="sfz" class="block mb-2 text-sm text-gray-700 font-medium dark:text-white">中国大陆身份证号</label>
|
||||
<input type="text" name="sfz" id="sfz" autocomplete="email" id="email" name="email" class="py-3 px-4 block w-full border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600">
|
||||
</div>';
|
||||
break;
|
||||
case 'realname':
|
||||
echo '<div>
|
||||
<label for="sfz" class="block mb-2 text-sm text-gray-700 font-medium dark:text-white">真实姓名</label>
|
||||
<input type="text" name="sfz" id="sfz" autocomplete="email" id="email" name="email" class="py-3 px-4 block w-full border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 dark:placeholder-neutral-500 dark:focus:ring-neutral-600">
|
||||
</div>';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<!-- Checkbox -->
|
||||
<div class="mt-3 flex border-gray-200">
|
||||
<div class="flex">
|
||||
<input id="remember-me" name="remember-me" type="checkbox" class="shrink-0 mt-1.5 border-gray-800 rounded text-blue-600 focus:ring-blue-500 dark:bg-neutral-800 dark:border-neutral-700 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-800">
|
||||
</div>
|
||||
<div class="ms-3">
|
||||
<label for="remember-me" class=" text-sm text-gray-600 dark:text-neutral-400">您已了解并同意来笙<a class="text-blue-600 decoration-2 hover:underline focus:outline-none focus:underline font-medium dark:text-blue-500" href="#">隐私条款</a>,同意来笙安全地处理和储存您的个人信息,并在您同意和授权的前提下安全地提供给第三方应用使用。</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Checkbox -->
|
||||
|
||||
<div class="mt-6 grid">
|
||||
<button type="submit" class="w-full py-3 px-4 inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 focus:outline-none focus:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none">完善信息</button>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 text-center">
|
||||
<p class="text-sm text-gray-500 dark:text-neutral-500">
|
||||
您的信息将被加密处理和储存,来笙不会保存您的身份证号等敏感内容。<br />仅限中国大陆用户使用,国际用户请咨询 admin@laysense.com
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
<!-- End Form -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-3 flex justify-center items-center text-center divide-x divide-gray-300 dark:divide-neutral-700">
|
||||
©上海来笙信息科技有限公司 2024 </p>
|
||||
|
||||
|
||||
</main>
|
||||
<!-- ========== END MAIN CONTENT ========== -->
|
||||
|
||||
<!-- JS Implementing Plugins -->
|
||||
|
||||
<!-- JS PLUGINS -->
|
||||
<!-- Required plugins -->
|
||||
<script src="https://static.laysense.cn/data/file/cdn/preline.js"></script>
|
||||
<script src="/jquery.js"></script>
|
||||
<script src="/distpicker.js"></script>
|
||||
<script>
|
||||
|
||||
document.querySelector('#avatar').onchange = function (){
|
||||
if(this.files.length){
|
||||
let file = this.files[0];
|
||||
let reader = new FileReader();
|
||||
//新建 FileReader 对象
|
||||
reader.onload = function(){
|
||||
// 当 FileReader 读取文件时候,读取的结果会放在 FileReader.result 属性中
|
||||
document.querySelector('#avatarpreview').src = this.result;
|
||||
};
|
||||
// 设置以什么方式读取文件,这里以base64方式
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<!-- JS THIRD PARTY PLUGINS -->
|
||||
</body>
|
||||
</html>
|
@ -1,4 +1,4 @@
|
||||
<?php if(!isset($special)){ $special=false;}?>
|
||||
<?php if(!isset($special)||$special==''){ $special='false';}?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" class="h-full">
|
||||
<head>
|
||||
@ -86,11 +86,14 @@
|
||||
<div class="py-3 flex items-center text-xs text-gray-400 uppercase before:flex-1 before:border-t before:border-gray-200 before:me-6 after:flex-1 after:border-t after:border-gray-200 after:ms-6 dark:text-neutral-500 dark:before:border-neutral-600 dark:after:border-neutral-600">来笙内部登录</div>
|
||||
|
||||
<div >
|
||||
<a href="https://login.work.weixin.qq.com/wwlogin/sso/login?login_type=CorpApp&appid=<?php echo(getenv('appid'));?>&agentid=<?php echo(getenv('agentid'));?>&redirect_uri=https://<?php echo(getenv('weburl'));?>/auth/lay/<?php echo($app->ID);?>/qywx/callback" class=" mb-4 w-full py-3 px-4 inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-teal-100 text-teal-800 hover:bg-teal-200 focus:outline-none focus:bg-teal-200 disabled:opacity-50 disabled:pointer-events-none dark:text-teal-500 dark:bg-teal-800/30 dark:hover:bg-teal-800/20 dark:focus:bg-teal-800/20">
|
||||
<!--a href="https://login.work.weixin.qq.com/wwlogin/sso/login?login_type=CorpApp&appid=<?php echo(getenv('appid'));?>&agentid=<?php echo(getenv('agentid'));?>&redirect_uri=<?php echo($redirecturl);?>/qywx/callback" class=" mb-4 w-full py-3 px-4 inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-teal-100 text-teal-800 hover:bg-teal-200 focus:outline-none focus:bg-teal-200 disabled:opacity-50 disabled:pointer-events-none dark:text-teal-500 dark:bg-teal-800/30 dark:hover:bg-teal-800/20 dark:focus:bg-teal-800/20">
|
||||
<svg t="1722953611732" class="icon" viewBox="0 0 1229 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4326" width="24" height="24"><path d="M702.72 849.92c-76.8 30.72-158.72 35.84-240.64 30.72-35.84-5.12-71.68-10.24-107.52-20.48-5.12 0-10.24 0-15.36 5.12-46.08 20.48-92.16 46.08-133.12 66.56-15.36 10.24-30.72 10.24-46.08 0s-15.36-25.6-15.36-46.08c10.24-35.84 10.24-71.68 15.36-107.52 0-5.12-5.12-10.24-5.12-15.36-51.2-51.2-92.16-102.4-122.88-168.96-51.2-122.88-40.96-245.76 30.72-358.4C134.4 112.64 247.04 46.08 380.16 15.36S641.28 0 764.16 61.44c112.64 56.32 194.56 143.36 230.4 266.24 15.36 46.08 20.48 92.16 15.36 138.24-25.6-25.6-56.32-30.72-87.04-15.36 0-30.72 0-61.44-10.24-92.16-20.48-71.68-61.44-128-112.64-174.08-87.04-71.68-194.56-102.4-307.2-102.4-117.76 10.24-220.16 51.2-302.08 133.12-66.56 66.56-102.4 148.48-97.28 245.76 5.12 81.92 40.96 148.48 92.16 204.8l40.96 40.96c20.48 15.36 25.6 30.72 15.36 51.2-5.12 20.48-10.24 46.08-15.36 66.56 0 5.12-5.12 10.24 0 10.24 5.12 5.12 10.24 0 10.24 0 25.6-15.36 56.32-30.72 81.92-51.2 15.36-10.24 30.72-10.24 51.2-5.12 87.04 25.6 179.2 25.6 266.24 0 5.12 0 10.24-5.12 10.24 5.12 10.24 30.72 25.6 51.2 56.32 66.56z" fill="#0082EF" p-id="4327"></path><path d="M1214.72 747.52c0 35.84-25.6 61.44-56.32 66.56-51.2 10.24-92.16 30.72-128 66.56-10.24 10.24-15.36 10.24-25.6 5.12-5.12-5.12-5.12-15.36 0-25.6 35.84-35.84 56.32-81.92 66.56-128 5.12-35.84 40.96-56.32 76.8-56.32 40.96 5.12 66.56 35.84 66.56 71.68z" fill="#0081EE" p-id="4328"></path><path d="M953.6 1024c-35.84 0-66.56-25.6-71.68-56.32-5.12-51.2-30.72-92.16-66.56-122.88-5.12-5.12-10.24-10.24-5.12-20.48 5.12-15.36 15.36-15.36 25.6-10.24 10.24 5.12 15.36 15.36 20.48 20.48 30.72 25.6 66.56 40.96 102.4 46.08 35.84 5.12 61.44 40.96 56.32 76.8 5.12 35.84-25.6 66.56-61.44 66.56z" fill="#FA6202" p-id="4329"></path><path d="M682.24 757.76c0-35.84 20.48-61.44 56.32-71.68 51.2-10.24 92.16-30.72 128-66.56 10.24-10.24 20.48-10.24 25.6 0 5.12 5.12 5.12 15.36-5.12 25.6-30.72 30.72-51.2 66.56-61.44 112.64 0 5.12 0 15.36-5.12 20.48-10.24 35.84-40.96 56.32-76.8 51.2-35.84-5.12-61.44-35.84-61.44-71.68z" fill="#FECD00" p-id="4330"></path><path d="M1035.52 578.56c15.36 30.72 30.72 56.32 51.2 76.8 10.24 10.24 10.24 20.48 5.12 25.6-5.12 10.24-15.36 10.24-25.6 0-25.6-30.72-61.44-51.2-97.28-61.44-10.24-5.12-20.48-5.12-30.72-5.12-20.48-5.12-40.96-15.36-46.08-40.96-10.24-25.6-10.24-51.2 10.24-71.68 20.48-25.6 46.08-30.72 71.68-25.6 25.6 10.24 46.08 25.6 51.2 56.32 0 15.36 5.12 30.72 10.24 46.08z" fill="#2CBD00" p-id="4331"></path></svg>
|
||||
企业微信登录
|
||||
</a-->
|
||||
<a href="/qywxoauth/?rd=<?php echo($redirecturl);?>&sum=<?php echo(md5($redirecturl.getenv('aeskey')));?>" class=" mb-4 w-full py-3 px-4 inline-flex justify-center items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-teal-100 text-teal-800 hover:bg-teal-200 focus:outline-none focus:bg-teal-200 disabled:opacity-50 disabled:pointer-events-none dark:text-teal-500 dark:bg-teal-800/30 dark:hover:bg-teal-800/20 dark:focus:bg-teal-800/20">
|
||||
<svg t="1722953611732" class="icon" viewBox="0 0 1229 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4326" width="24" height="24"><path d="M702.72 849.92c-76.8 30.72-158.72 35.84-240.64 30.72-35.84-5.12-71.68-10.24-107.52-20.48-5.12 0-10.24 0-15.36 5.12-46.08 20.48-92.16 46.08-133.12 66.56-15.36 10.24-30.72 10.24-46.08 0s-15.36-25.6-15.36-46.08c10.24-35.84 10.24-71.68 15.36-107.52 0-5.12-5.12-10.24-5.12-15.36-51.2-51.2-92.16-102.4-122.88-168.96-51.2-122.88-40.96-245.76 30.72-358.4C134.4 112.64 247.04 46.08 380.16 15.36S641.28 0 764.16 61.44c112.64 56.32 194.56 143.36 230.4 266.24 15.36 46.08 20.48 92.16 15.36 138.24-25.6-25.6-56.32-30.72-87.04-15.36 0-30.72 0-61.44-10.24-92.16-20.48-71.68-61.44-128-112.64-174.08-87.04-71.68-194.56-102.4-307.2-102.4-117.76 10.24-220.16 51.2-302.08 133.12-66.56 66.56-102.4 148.48-97.28 245.76 5.12 81.92 40.96 148.48 92.16 204.8l40.96 40.96c20.48 15.36 25.6 30.72 15.36 51.2-5.12 20.48-10.24 46.08-15.36 66.56 0 5.12-5.12 10.24 0 10.24 5.12 5.12 10.24 0 10.24 0 25.6-15.36 56.32-30.72 81.92-51.2 15.36-10.24 30.72-10.24 51.2-5.12 87.04 25.6 179.2 25.6 266.24 0 5.12 0 10.24-5.12 10.24 5.12 10.24 30.72 25.6 51.2 56.32 66.56z" fill="#0082EF" p-id="4327"></path><path d="M1214.72 747.52c0 35.84-25.6 61.44-56.32 66.56-51.2 10.24-92.16 30.72-128 66.56-10.24 10.24-15.36 10.24-25.6 5.12-5.12-5.12-5.12-15.36 0-25.6 35.84-35.84 56.32-81.92 66.56-128 5.12-35.84 40.96-56.32 76.8-56.32 40.96 5.12 66.56 35.84 66.56 71.68z" fill="#0081EE" p-id="4328"></path><path d="M953.6 1024c-35.84 0-66.56-25.6-71.68-56.32-5.12-51.2-30.72-92.16-66.56-122.88-5.12-5.12-10.24-10.24-5.12-20.48 5.12-15.36 15.36-15.36 25.6-10.24 10.24 5.12 15.36 15.36 20.48 20.48 30.72 25.6 66.56 40.96 102.4 46.08 35.84 5.12 61.44 40.96 56.32 76.8 5.12 35.84-25.6 66.56-61.44 66.56z" fill="#FA6202" p-id="4329"></path><path d="M682.24 757.76c0-35.84 20.48-61.44 56.32-71.68 51.2-10.24 92.16-30.72 128-66.56 10.24-10.24 20.48-10.24 25.6 0 5.12 5.12 5.12 15.36-5.12 25.6-30.72 30.72-51.2 66.56-61.44 112.64 0 5.12 0 15.36-5.12 20.48-10.24 35.84-40.96 56.32-76.8 51.2-35.84-5.12-61.44-35.84-61.44-71.68z" fill="#FECD00" p-id="4330"></path><path d="M1035.52 578.56c15.36 30.72 30.72 56.32 51.2 76.8 10.24 10.24 10.24 20.48 5.12 25.6-5.12 10.24-15.36 10.24-25.6 0-25.6-30.72-61.44-51.2-97.28-61.44-10.24-5.12-20.48-5.12-30.72-5.12-20.48-5.12-40.96-15.36-46.08-40.96-10.24-25.6-10.24-51.2 10.24-71.68 20.48-25.6 46.08-30.72 71.68-25.6 25.6 10.24 46.08 25.6 51.2 56.32 0 15.36 5.12 30.72 10.24 46.08z" fill="#2CBD00" p-id="4331"></path></svg>
|
||||
企业微信登录
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
84
app/view/block.html
Normal file
84
app/view/block.html
Normal file
@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" class="h-full">
|
||||
<head>
|
||||
<!-- Required Meta Tags Always Come First -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="Laysense Auth">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<title>Laysense Auth</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="https://static.laysense.cn/data/file/_4335ce.png?1709117691655">
|
||||
|
||||
<!-- Font -->
|
||||
|
||||
<!-- Theme Check and Update -->
|
||||
<script>
|
||||
const html = document.querySelector('html');
|
||||
const isLightOrAuto = localStorage.getItem('hs_theme') === 'light' || (localStorage.getItem('hs_theme') === 'auto' && !window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
const isDarkOrAuto = localStorage.getItem('hs_theme') === 'dark' || (localStorage.getItem('hs_theme') === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
|
||||
if (isLightOrAuto && html.classList.contains('dark')) html.classList.remove('dark');
|
||||
else if (isDarkOrAuto && html.classList.contains('light')) html.classList.remove('light');
|
||||
else if (isDarkOrAuto && !html.classList.contains('dark')) html.classList.add('dark');
|
||||
else if (isLightOrAuto && !html.classList.contains('light')) html.classList.add('light');
|
||||
</script>
|
||||
|
||||
<!-- CSS HS -->
|
||||
<link rel="stylesheet" href="https://static.laysense.cn/data/file/cdn/preline.css">
|
||||
</head>
|
||||
|
||||
<body class="flex h-full items-center py-16 dark:bg-neutral-800" background="https://bing.img.run/1920x1080.php" style="background-size: 100% 100%;">
|
||||
<!-- ========== MAIN CONTENT ========== -->
|
||||
<main id="content" class="w-full max-w-md mx-auto p-6">
|
||||
|
||||
<div class="mt-7 border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-900 dark:border-neutral-700" style="background: rgba(255, 255, 255, 0.6);-webkit-backdrop-filter: blur(10px);backdrop-filter: blur(10px);">
|
||||
<div class="p-4 sm:p-7">
|
||||
<div class="text-center">
|
||||
<h1 class="block text-2xl font-bold text-gray-800 dark:text-white" ><img src="https://static.laysense.cn/data/file/laysenseW.png" style="height:30px;" />应用授权请求被拒绝</h1>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-neutral-400">
|
||||
抱歉,由于:<?php echo($app->reason);?>,该应用的授权请求已被拒绝,您可以:
|
||||
<a class="text-blue-600 decoration-2 hover:underline focus:outline-none focus:underline font-medium dark:text-blue-500" href="https://laysense.cn/" target="_blank">
|
||||
前往来笙
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="py-3 flex items-center text-xs text-gray-400 uppercase before:flex-1 before:border-t before:border-gray-200 before:me-6 after:flex-1 after:border-t after:border-gray-200 after:ms-6 dark:text-neutral-500 dark:before:border-neutral-600 dark:after:border-neutral-600">请求授权的APP</div>
|
||||
|
||||
<div class="shrink-0 group block ">
|
||||
<div class="flex items-center">
|
||||
<img class="inline-block shrink-0 size-[62px] rounded-full" src="<?php echo($app->img);?>" alt="Avatar">
|
||||
<div class="ms-3">
|
||||
<h3 class="font-semibold text-gray-800 dark:text-white"><?php echo($app->name);?></h3>
|
||||
<p class="text-sm font-medium text-gray-400 dark:text-neutral-500"><?php echo($app->info);?></p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-neutral-400 text-center" >
|
||||
由
|
||||
<a class="text-blue-600 decoration-2 hover:underline focus:outline-none focus:underline font-medium dark:text-blue-500" href="<?php echo($provider->url);?>" target="_blank">
|
||||
<?php echo($provider->name);?>
|
||||
</a>
|
||||
提供
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-3 flex justify-center items-center text-center divide-x divide-gray-300 dark:divide-neutral-700">
|
||||
©上海来笙信息科技有限公司 2024 </p>
|
||||
|
||||
</main>
|
||||
<!-- ========== END MAIN CONTENT ========== -->
|
||||
|
||||
<!-- JS Implementing Plugins -->
|
||||
|
||||
<!-- JS PLUGINS -->
|
||||
<!-- Required plugins -->
|
||||
<script src="https://static.laysense.cn/data/file/cdn/preline.js"></script>
|
||||
|
||||
<!-- JS THIRD PARTY PLUGINS -->
|
||||
</body>
|
||||
</html>
|
65
app/view/qywx/expire.html
Normal file
65
app/view/qywx/expire.html
Normal file
@ -0,0 +1,65 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" class="h-full">
|
||||
<head>
|
||||
<!-- Required Meta Tags Always Come First -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="Laysense Auth">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<title>Laysense Auth</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="https://static.laysense.cn/data/file/_4335ce.png?1709117691655">
|
||||
|
||||
<!-- Font -->
|
||||
|
||||
<!-- Theme Check and Update -->
|
||||
<script>
|
||||
const html = document.querySelector('html');
|
||||
const isLightOrAuto = localStorage.getItem('hs_theme') === 'light' || (localStorage.getItem('hs_theme') === 'auto' && !window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
const isDarkOrAuto = localStorage.getItem('hs_theme') === 'dark' || (localStorage.getItem('hs_theme') === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
|
||||
if (isLightOrAuto && html.classList.contains('dark')) html.classList.remove('dark');
|
||||
else if (isDarkOrAuto && html.classList.contains('light')) html.classList.remove('light');
|
||||
else if (isDarkOrAuto && !html.classList.contains('dark')) html.classList.add('dark');
|
||||
else if (isLightOrAuto && !html.classList.contains('light')) html.classList.add('light');
|
||||
</script>
|
||||
|
||||
<!-- CSS HS -->
|
||||
<link rel="stylesheet" href="https://static.laysense.cn/data/file/cdn/preline.css">
|
||||
</head>
|
||||
|
||||
<body class="flex h-full items-center py-16 dark:bg-neutral-800" background="https://bing.img.run/1920x1080.php" style="background-size: 100% 100%;">
|
||||
<!-- ========== MAIN CONTENT ========== -->
|
||||
<main id="content" class="w-full max-w-md mx-auto p-6">
|
||||
|
||||
<div class="mt-7 border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-900 dark:border-neutral-700" style="background: rgba(255, 255, 255, 0.6);-webkit-backdrop-filter: blur(10px);backdrop-filter: blur(10px);">
|
||||
<div class="p-4 sm:p-7">
|
||||
<div class="text-center">
|
||||
<h1 class="block text-2xl font-bold text-gray-800 dark:text-white" ><img src="https://static.laysense.cn/data/file/laysenseW.png" style="height:30px;" />登陆已过期</h1>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-neutral-400">
|
||||
当前登录请求已失效,请回到原页面重试。
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-3 flex justify-center items-center text-center divide-x divide-gray-300 dark:divide-neutral-700">
|
||||
©上海来笙信息科技有限公司 2024 </p>
|
||||
|
||||
</main>
|
||||
<!-- ========== END MAIN CONTENT ========== -->
|
||||
|
||||
<!-- JS Implementing Plugins -->
|
||||
|
||||
<!-- JS PLUGINS -->
|
||||
<!-- Required plugins -->
|
||||
<script src="https://static.laysense.cn/data/file/cdn/preline.js"></script>
|
||||
|
||||
<!-- JS THIRD PARTY PLUGINS -->
|
||||
</body>
|
||||
</html>
|
69
app/view/qywx/success.html
Normal file
69
app/view/qywx/success.html
Normal file
@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" class="h-full">
|
||||
<head>
|
||||
<!-- Required Meta Tags Always Come First -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="Laysense Auth">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<title>Laysense Auth</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="https://static.laysense.cn/data/file/_4335ce.png?1709117691655">
|
||||
|
||||
<!-- Font -->
|
||||
|
||||
<!-- Theme Check and Update -->
|
||||
<script>
|
||||
const html = document.querySelector('html');
|
||||
const isLightOrAuto = localStorage.getItem('hs_theme') === 'light' || (localStorage.getItem('hs_theme') === 'auto' && !window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
const isDarkOrAuto = localStorage.getItem('hs_theme') === 'dark' || (localStorage.getItem('hs_theme') === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
|
||||
if (isLightOrAuto && html.classList.contains('dark')) html.classList.remove('dark');
|
||||
else if (isDarkOrAuto && html.classList.contains('light')) html.classList.remove('light');
|
||||
else if (isDarkOrAuto && !html.classList.contains('dark')) html.classList.add('dark');
|
||||
else if (isLightOrAuto && !html.classList.contains('light')) html.classList.add('light');
|
||||
</script>
|
||||
|
||||
<!-- CSS HS -->
|
||||
<link rel="stylesheet" href="https://static.laysense.cn/data/file/cdn/preline.css">
|
||||
</head>
|
||||
|
||||
<body class="flex h-full items-center py-16 dark:bg-neutral-800" background="https://bing.img.run/1920x1080.php" style="background-size: 100% 100%;">
|
||||
<!-- ========== MAIN CONTENT ========== -->
|
||||
<main id="content" class="w-full max-w-md mx-auto p-6">
|
||||
|
||||
<div class="mt-7 border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-900 dark:border-neutral-700" style="background: rgba(255, 255, 255, 0.6);-webkit-backdrop-filter: blur(10px);backdrop-filter: blur(10px);">
|
||||
<div class="p-4 sm:p-7">
|
||||
<div class="text-center">
|
||||
<h1 class="block text-2xl font-bold text-gray-800 dark:text-white" ><img src="https://static.laysense.cn/data/file/laysenseW.png" style="height:30px;" />授权登录成功</h1>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-neutral-400">
|
||||
您已成功登录,请回到网页源页面操作,您可以关闭本页面。
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="mt-3 flex justify-center items-center text-center divide-x divide-gray-300 dark:divide-neutral-700">
|
||||
©上海来笙信息科技有限公司 2024 </p>
|
||||
|
||||
|
||||
</main>
|
||||
<!-- ========== END MAIN CONTENT ========== -->
|
||||
|
||||
<!-- JS Implementing Plugins -->
|
||||
|
||||
<!-- JS PLUGINS -->
|
||||
<!-- Required plugins -->
|
||||
<script src="https://static.laysense.cn/data/file/cdn/preline.js"></script>
|
||||
|
||||
<!-- JS THIRD PARTY PLUGINS -->
|
||||
</body>
|
||||
</html>
|
116
app/view/qywx/wait.html
Normal file
116
app/view/qywx/wait.html
Normal file
@ -0,0 +1,116 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" class="h-full">
|
||||
<head>
|
||||
<!-- Required Meta Tags Always Come First -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="Laysense Auth">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<title>Laysense Auth</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="https://static.laysense.cn/data/file/_4335ce.png?1709117691655">
|
||||
|
||||
<!-- Font -->
|
||||
|
||||
<!-- Theme Check and Update -->
|
||||
<script>
|
||||
const html = document.querySelector('html');
|
||||
const isLightOrAuto = localStorage.getItem('hs_theme') === 'light' || (localStorage.getItem('hs_theme') === 'auto' && !window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
const isDarkOrAuto = localStorage.getItem('hs_theme') === 'dark' || (localStorage.getItem('hs_theme') === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
|
||||
if (isLightOrAuto && html.classList.contains('dark')) html.classList.remove('dark');
|
||||
else if (isDarkOrAuto && html.classList.contains('light')) html.classList.remove('light');
|
||||
else if (isDarkOrAuto && !html.classList.contains('dark')) html.classList.add('dark');
|
||||
else if (isLightOrAuto && !html.classList.contains('light')) html.classList.add('light');
|
||||
</script>
|
||||
|
||||
<!-- CSS HS -->
|
||||
<link rel="stylesheet" href="https://static.laysense.cn/data/file/cdn/preline.css">
|
||||
</head>
|
||||
|
||||
<body class="flex h-full items-center py-16 dark:bg-neutral-800" background="https://bing.img.run/1920x1080.php" style="background-size: 100% 100%;">
|
||||
<!-- ========== MAIN CONTENT ========== -->
|
||||
<main id="content" class="w-full max-w-md mx-auto p-6">
|
||||
|
||||
<div class="mt-7 border border-gray-200 rounded-xl shadow-sm dark:bg-neutral-900 dark:border-neutral-700" style="background: rgba(255, 255, 255, 0.6);-webkit-backdrop-filter: blur(10px);backdrop-filter: blur(10px);">
|
||||
<div class="p-4 sm:p-7">
|
||||
<div class="text-center">
|
||||
<h1 class="block text-2xl font-bold text-gray-800 dark:text-white" ><img src="https://static.laysense.cn/data/file/laysenseW.png" style="height:30px;" />请使用企业微信扫码登陆</h1>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-neutral-400">
|
||||
二维码有效期 <span class="text-blue-600 decoration-2 hover:underline focus:outline-none focus:underline font-medium dark:text-blue-500" >5分钟</span> 超时请刷新页面
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="py-3 flex items-center text-xs text-gray-400 uppercase before:flex-1 before:border-t before:border-gray-200 before:me-6 after:flex-1 after:border-t after:border-gray-200 after:ms-6 dark:text-neutral-500 dark:before:border-neutral-600 dark:after:border-neutral-600">登录二维码</div>
|
||||
|
||||
<div class="shrink-0 group block ">
|
||||
<div class="flex items-center" id="qrdiv">
|
||||
<img src="<?php echo($qr);?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="mt-3 flex justify-center items-center text-center divide-x divide-gray-300 dark:divide-neutral-700">
|
||||
©上海来笙信息科技有限公司 2024 </p>
|
||||
|
||||
|
||||
</main>
|
||||
<!-- ========== END MAIN CONTENT ========== -->
|
||||
|
||||
<!-- JS Implementing Plugins -->
|
||||
|
||||
<!-- JS PLUGINS -->
|
||||
<!-- Required plugins -->
|
||||
<script src="https://static.laysense.cn/data/file/cdn/preline.js"></script>
|
||||
|
||||
<!-- JS THIRD PARTY PLUGINS -->
|
||||
<script src="/jquery.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
//定义code
|
||||
var code;
|
||||
//获取code TODO:
|
||||
getStatusLong();
|
||||
// 长轮询执行
|
||||
function getStatusLong()
|
||||
{
|
||||
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: "<?php echo('/qywxoauth/ask/'.$uuid);?>",
|
||||
success: function(response) {
|
||||
if (response.code == 200) {
|
||||
window.location = "<?php echo($to.'?code=');?>"+response.rcode;
|
||||
}else if(response.code == 500||response.code == 503){
|
||||
// 二维码已经过期
|
||||
$('#qrdiv').html('二维码已超时,请刷新页面重试');
|
||||
}else if(response.code == 501){
|
||||
$('#qrdiv').html('参数错误,请重新进行登录');
|
||||
}
|
||||
},
|
||||
dataType: 'json',
|
||||
timeout: 300*1000,// 超时时间
|
||||
// 超时意味着出错了
|
||||
error: function (error) {
|
||||
console.log(error);// timeout
|
||||
$('#qrdiv').html('二维码已超时,请刷新页面重试');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -43,7 +43,9 @@
|
||||
"workerman/crontab": "^1.0",
|
||||
"yzh52521/easyhttp": "^1.1",
|
||||
"firebase/php-jwt": "^6.10",
|
||||
"paragonie/sodium_compat": "^1.21"
|
||||
"paragonie/sodium_compat": "^1.21",
|
||||
"ramsey/uuid": "^4.7",
|
||||
"tekintian/phpqrcode": "^1.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-event": "For better performance. "
|
||||
|
246
composer.lock
generated
246
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "b72fd36b9d0fa83e2f5089cebfa3e871",
|
||||
"content-hash": "96596162cf0751a3f84fd78ea8ac0ed0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
@ -2761,6 +2761,200 @@
|
||||
},
|
||||
"time": "2019-03-08T08:55:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ramsey/collection",
|
||||
"version": "1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ramsey/collection.git",
|
||||
"reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ramsey/collection/zipball/ad7475d1c9e70b190ecffc58f2d989416af339b4",
|
||||
"reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0",
|
||||
"symfony/polyfill-php81": "^1.23"
|
||||
},
|
||||
"require-dev": {
|
||||
"captainhook/plugin-composer": "^5.3",
|
||||
"ergebnis/composer-normalize": "^2.28.3",
|
||||
"fakerphp/faker": "^1.21",
|
||||
"hamcrest/hamcrest-php": "^2.0",
|
||||
"jangregor/phpstan-prophecy": "^1.0",
|
||||
"mockery/mockery": "^1.5",
|
||||
"php-parallel-lint/php-console-highlighter": "^1.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3",
|
||||
"phpcsstandards/phpcsutils": "^1.0.0-rc1",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpstan/extension-installer": "^1.2",
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"phpstan/phpstan-mockery": "^1.1",
|
||||
"phpstan/phpstan-phpunit": "^1.3",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"psalm/plugin-mockery": "^1.1",
|
||||
"psalm/plugin-phpunit": "^0.18.4",
|
||||
"ramsey/coding-standard": "^2.0.3",
|
||||
"ramsey/conventional-commits": "^1.3",
|
||||
"vimeo/psalm": "^5.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"captainhook": {
|
||||
"force-install": true
|
||||
},
|
||||
"ramsey/conventional-commits": {
|
||||
"configFile": "conventional-commits.json"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Ramsey\\Collection\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ben Ramsey",
|
||||
"email": "ben@benramsey.com",
|
||||
"homepage": "https://benramsey.com"
|
||||
}
|
||||
],
|
||||
"description": "A PHP library for representing and manipulating collections.",
|
||||
"keywords": [
|
||||
"array",
|
||||
"collection",
|
||||
"hash",
|
||||
"map",
|
||||
"queue",
|
||||
"set"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ramsey/collection/issues",
|
||||
"source": "https://github.com/ramsey/collection/tree/1.3.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/ramsey",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/ramsey/collection",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-12-27T19:12:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ramsey/uuid",
|
||||
"version": "4.7.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ramsey/uuid.git",
|
||||
"reference": "5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ramsey/uuid/zipball/5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e",
|
||||
"reference": "5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11",
|
||||
"ext-json": "*",
|
||||
"php": "^8.0",
|
||||
"ramsey/collection": "^1.2 || ^2.0"
|
||||
},
|
||||
"replace": {
|
||||
"rhumsaa/uuid": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"captainhook/captainhook": "^5.10",
|
||||
"captainhook/plugin-composer": "^5.3",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"doctrine/annotations": "^1.8",
|
||||
"ergebnis/composer-normalize": "^2.15",
|
||||
"mockery/mockery": "^1.3",
|
||||
"paragonie/random-lib": "^2",
|
||||
"php-mock/php-mock": "^2.2",
|
||||
"php-mock/php-mock-mockery": "^1.3",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.1",
|
||||
"phpbench/phpbench": "^1.0",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"phpstan/phpstan-mockery": "^1.1",
|
||||
"phpstan/phpstan-phpunit": "^1.1",
|
||||
"phpunit/phpunit": "^8.5 || ^9",
|
||||
"ramsey/composer-repl": "^1.4",
|
||||
"slevomat/coding-standard": "^8.4",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"vimeo/psalm": "^4.9"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.",
|
||||
"ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.",
|
||||
"ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.",
|
||||
"paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
|
||||
"ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"captainhook": {
|
||||
"force-install": true
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Ramsey\\Uuid\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "A PHP library for generating and working with universally unique identifiers (UUIDs).",
|
||||
"keywords": [
|
||||
"guid",
|
||||
"identifier",
|
||||
"uuid"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ramsey/uuid/issues",
|
||||
"source": "https://github.com/ramsey/uuid/tree/4.7.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/ramsey",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/ramsey/uuid",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-11-08T05:53:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "respect/stringifier",
|
||||
"version": "0.2.0",
|
||||
@ -4470,6 +4664,56 @@
|
||||
],
|
||||
"time": "2023-01-13T08:34:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tekintian/phpqrcode",
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tekintian/phpqrcode.git",
|
||||
"reference": "8bc8c1189981a5dbd0d7a50fd6db4899834beff9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tekintian/phpqrcode/zipball/8bc8c1189981a5dbd0d7a50fd6db4899834beff9",
|
||||
"reference": "8bc8c1189981a5dbd0d7a50fd6db4899834beff9",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.3|^7.0|^8.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"tekintian\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"description": "支持PHP5.3至php8.2的 qrcode 二维码工具类 改进版本,支持自定义LOGO,自定义输出目录和自定义返回类型 图片,base64图片数据, 二维码图片自定义,静态方法调用,方便快捷,高效,简洁的PHP二维码生成工具",
|
||||
"homepage": "https://github.com/tekintian/phpqrcode",
|
||||
"keywords": [
|
||||
"PHP二维码",
|
||||
"php qrcode with logo",
|
||||
"phpqrcode",
|
||||
"qrcode",
|
||||
"tiny qrcode",
|
||||
"二维码工具"
|
||||
],
|
||||
"support": {
|
||||
"forum": "https://github.com/tekintian/phpqrcode",
|
||||
"issues": "https://github.com/tekintian/phpqrcode/issues",
|
||||
"source": "https://github.com/tekintian/phpqrcode"
|
||||
},
|
||||
"time": "2023-11-06T12:08:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "vlucas/phpdotenv",
|
||||
"version": "v5.6.0",
|
||||
|
@ -15,6 +15,6 @@
|
||||
return [
|
||||
'' => [
|
||||
// ... 这里省略其它中间件
|
||||
app\middleware\Listen::class,
|
||||
#app\middleware\Listen::class,
|
||||
]
|
||||
];
|
@ -15,8 +15,8 @@
|
||||
return [
|
||||
'default' => [
|
||||
'host' => '127.0.0.1',
|
||||
'password' => null,
|
||||
'password' => getenv('redis_password'),
|
||||
'port' => 6379,
|
||||
'database' => 0,
|
||||
'database' => 2,
|
||||
],
|
||||
];
|
||||
|
@ -18,7 +18,8 @@ use Webman\Route;
|
||||
#Laysense Simple Login
|
||||
Route::group('/auth/lay', function () {
|
||||
Route::any('/{appid}',[app\controller\LayAuth::class, 'index']);
|
||||
Route::any('/{appid}/{gateway}/callback',[app\controller\LayAuth::class, 'callback']);
|
||||
#Route::any('/{appid}/{gateway}/callback',[app\controller\LayAuth::class, 'callback']);
|
||||
Route::any('/{appid}/callback',[app\controller\LayAuth::class, 'callback']);
|
||||
Route::any('/{appid}/check',[app\controller\LayAuth::class, 'check']);
|
||||
});
|
||||
|
||||
@ -26,10 +27,31 @@ Route::group('/auth/lay', function () {
|
||||
Route::group('/auth/oauth', function () {
|
||||
Route::any('/authorize',[app\controller\OAuth::class, 'authorize']);
|
||||
Route::any('/token',[app\controller\OAuth::class, 'token']);
|
||||
#Route::any('/back/{appid}/{gateway}/callback',[app\controller\OAuth::class, 'callback']);
|
||||
Route::any('/back/{appid}',[app\controller\OAuth::class, 'callback']);
|
||||
Route::any('/userinfo',[app\controller\OAuth::class, 'userinfo']);
|
||||
|
||||
});
|
||||
|
||||
Route::group('/qywxoauth', function () {
|
||||
Route::any('/',[app\controller\QywxOauth::class, 'index']);
|
||||
Route::any('/answer/{uuid}',[app\controller\QywxOauth::class, 'answer']);
|
||||
Route::any('/ask/{uuid}',[app\controller\QywxOauth::class, 'ask']);
|
||||
Route::any('/info',[app\controller\QywxOauth::class, 'info']);
|
||||
});
|
||||
|
||||
Route::group('/account', function () {
|
||||
Route::any('/loginCallback',[app\controller\Account::class, 'loginCallback']);
|
||||
Route::any('/info/extend',[app\controller\QywxOauth::class, 'answer']);
|
||||
Route::any('/ask/{uuid}',[app\controller\QywxOauth::class, 'ask']);
|
||||
Route::any('/info',[app\controller\QywxOauth::class, 'info']);
|
||||
});
|
||||
|
||||
Route::any('/addusertest',function(){
|
||||
$requireFields=['name','sex','email','avatar','phone','address','sfz','birthday','realname'];
|
||||
return view('account/extend', ['userid'=>'ShenZiQi@laysense','username'=>'沈子淇','requireFields'=>$requireFields]);
|
||||
});
|
||||
|
||||
|
||||
Route::fallback(function( $request){
|
||||
print_r($request);
|
||||
|
1
public/WW_verify_4Lyj7cQRdG8BfO9N.txt
Normal file
1
public/WW_verify_4Lyj7cQRdG8BfO9N.txt
Normal file
@ -0,0 +1 @@
|
||||
4Lyj7cQRdG8BfO9N
|
4387
public/distpicker.js
Normal file
4387
public/distpicker.js
Normal file
File diff suppressed because it is too large
Load Diff
2
public/jquery.js
vendored
Normal file
2
public/jquery.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
public/laysenseLogo.jpg
Normal file
BIN
public/laysenseLogo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
BIN
public/qywx.png
Normal file
BIN
public/qywx.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
@ -0,0 +1 @@
|
||||
a:1:{s:13:"QYWX_OAUTH_rd";s:44:"https://auth.laysense.cn/auth/lay/1/callback";}
|
@ -0,0 +1 @@
|
||||
a:1:{s:13:"QYWX_OAUTH_rd";s:44:"https://auth.laysense.cn/auth/lay/1/callback";}
|
@ -0,0 +1 @@
|
||||
a:1:{s:26:"laysensegit_oauth_redirect";s:58:"https://git.laysense.com/user/oauth2/LaysenseAuth/callback";}
|
@ -0,0 +1 @@
|
||||
a:1:{s:13:"QYWX_OAUTH_rd";s:44:"https://auth.laysense.cn/auth/lay/1/callback";}
|
@ -1 +0,0 @@
|
||||
204846
|
6
test.php
Normal file
6
test.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$str = "openid+";
|
||||
print_r (explode("+",$str));
|
||||
?>
|
||||
|
||||
https://open.weixin.qq.com/connect/oauth2/authorize?appid=wwce49066b07c69c75&redirect_uri=https://auth.laysense.cn/&response_type=code&scope=snsapi_privateinfo&state=STATE&agentid=1000008#wechat_redirect
|
3
vendor/composer/autoload_files.php
vendored
3
vendor/composer/autoload_files.php
vendored
@ -16,16 +16,17 @@ return array(
|
||||
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
|
||||
'8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
|
||||
'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
|
||||
'23c18046f52bef3eea034657bafda50f' => $vendorDir . '/symfony/polyfill-php81/bootstrap.php',
|
||||
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
|
||||
'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
|
||||
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
|
||||
'23c18046f52bef3eea034657bafda50f' => $vendorDir . '/symfony/polyfill-php81/bootstrap.php',
|
||||
'948ad5488880985ff1c06721a4e447fe' => $vendorDir . '/cakephp/utility/bootstrap.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
'253c157292f75eb38082b5acb06f3f01' => $vendorDir . '/nikic/fast-route/src/functions.php',
|
||||
'2df68f9e79c919e2d88506611769ed2e' => $vendorDir . '/respect/stringifier/src/stringify.php',
|
||||
'ef65a1626449d89d0811cf9befce46f0' => $vendorDir . '/illuminate/events/functions.php',
|
||||
'3109cb1a231dcd04bee1f9f620d46975' => $vendorDir . '/paragonie/sodium_compat/autoload.php',
|
||||
'e39a8b23c42d4e1452234d762b03835a' => $vendorDir . '/ramsey/uuid/src/functions.php',
|
||||
'667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
|
||||
'da5b71a9ad8465d48da441e2f36823b6' => $baseDir . '/support/helpers.php',
|
||||
);
|
||||
|
3
vendor/composer/autoload_psr4.php
vendored
3
vendor/composer/autoload_psr4.php
vendored
@ -8,6 +8,7 @@ $baseDir = dirname($vendorDir);
|
||||
return array(
|
||||
'yzh52521\\EasyHttp\\' => array($vendorDir . '/yzh52521/easyhttp/src'),
|
||||
'voku\\' => array($vendorDir . '/voku/portable-ascii/src/voku'),
|
||||
'tekintian\\' => array($vendorDir . '/tekintian/phpqrcode/src'),
|
||||
'support\\' => array($vendorDir . '/workerman/webman-framework/src/support'),
|
||||
'app\\View\\Components\\' => array($baseDir . '/app/view/components'),
|
||||
'app\\' => array($baseDir . '/app'),
|
||||
@ -39,6 +40,8 @@ return array(
|
||||
'Support\\' => array($vendorDir . '/workerman/webman-framework/src/support'),
|
||||
'Respect\\Validation\\' => array($vendorDir . '/workerman/validation/library'),
|
||||
'Respect\\Stringifier\\' => array($vendorDir . '/respect/stringifier/src'),
|
||||
'Ramsey\\Uuid\\' => array($vendorDir . '/ramsey/uuid/src'),
|
||||
'Ramsey\\Collection\\' => array($vendorDir . '/ramsey/collection/src'),
|
||||
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
|
||||
'Psr\\Log\\' => array($vendorDir . '/psr/log/src'),
|
||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
|
||||
|
21
vendor/composer/autoload_static.php
vendored
21
vendor/composer/autoload_static.php
vendored
@ -17,16 +17,17 @@ class ComposerStaticInitd3b2156d13053c4f5c49b090883e3785
|
||||
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
|
||||
'8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
|
||||
'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
|
||||
'23c18046f52bef3eea034657bafda50f' => __DIR__ . '/..' . '/symfony/polyfill-php81/bootstrap.php',
|
||||
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
||||
'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
|
||||
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
|
||||
'23c18046f52bef3eea034657bafda50f' => __DIR__ . '/..' . '/symfony/polyfill-php81/bootstrap.php',
|
||||
'948ad5488880985ff1c06721a4e447fe' => __DIR__ . '/..' . '/cakephp/utility/bootstrap.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
'253c157292f75eb38082b5acb06f3f01' => __DIR__ . '/..' . '/nikic/fast-route/src/functions.php',
|
||||
'2df68f9e79c919e2d88506611769ed2e' => __DIR__ . '/..' . '/respect/stringifier/src/stringify.php',
|
||||
'ef65a1626449d89d0811cf9befce46f0' => __DIR__ . '/..' . '/illuminate/events/functions.php',
|
||||
'3109cb1a231dcd04bee1f9f620d46975' => __DIR__ . '/..' . '/paragonie/sodium_compat/autoload.php',
|
||||
'e39a8b23c42d4e1452234d762b03835a' => __DIR__ . '/..' . '/ramsey/uuid/src/functions.php',
|
||||
'667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
|
||||
'da5b71a9ad8465d48da441e2f36823b6' => __DIR__ . '/../..' . '/support/helpers.php',
|
||||
);
|
||||
@ -40,6 +41,10 @@ class ComposerStaticInitd3b2156d13053c4f5c49b090883e3785
|
||||
array (
|
||||
'voku\\' => 5,
|
||||
),
|
||||
't' =>
|
||||
array (
|
||||
'tekintian\\' => 10,
|
||||
),
|
||||
's' =>
|
||||
array (
|
||||
'support\\' => 8,
|
||||
@ -85,6 +90,8 @@ class ComposerStaticInitd3b2156d13053c4f5c49b090883e3785
|
||||
array (
|
||||
'Respect\\Validation\\' => 19,
|
||||
'Respect\\Stringifier\\' => 20,
|
||||
'Ramsey\\Uuid\\' => 12,
|
||||
'Ramsey\\Collection\\' => 18,
|
||||
),
|
||||
'P' =>
|
||||
array (
|
||||
@ -159,6 +166,10 @@ class ComposerStaticInitd3b2156d13053c4f5c49b090883e3785
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/voku/portable-ascii/src/voku',
|
||||
),
|
||||
'tekintian\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/tekintian/phpqrcode/src',
|
||||
),
|
||||
'support\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/workerman/webman-framework/src/support',
|
||||
@ -283,6 +294,14 @@ class ComposerStaticInitd3b2156d13053c4f5c49b090883e3785
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/respect/stringifier/src',
|
||||
),
|
||||
'Ramsey\\Uuid\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/ramsey/uuid/src',
|
||||
),
|
||||
'Ramsey\\Collection\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/ramsey/collection/src',
|
||||
),
|
||||
'Psr\\SimpleCache\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/simple-cache/src',
|
||||
|
253
vendor/composer/installed.json
vendored
253
vendor/composer/installed.json
vendored
@ -2875,6 +2875,206 @@
|
||||
},
|
||||
"install-path": "../ralouphie/getallheaders"
|
||||
},
|
||||
{
|
||||
"name": "ramsey/collection",
|
||||
"version": "1.3.0",
|
||||
"version_normalized": "1.3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ramsey/collection.git",
|
||||
"reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ramsey/collection/zipball/ad7475d1c9e70b190ecffc58f2d989416af339b4",
|
||||
"reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0",
|
||||
"symfony/polyfill-php81": "^1.23"
|
||||
},
|
||||
"require-dev": {
|
||||
"captainhook/plugin-composer": "^5.3",
|
||||
"ergebnis/composer-normalize": "^2.28.3",
|
||||
"fakerphp/faker": "^1.21",
|
||||
"hamcrest/hamcrest-php": "^2.0",
|
||||
"jangregor/phpstan-prophecy": "^1.0",
|
||||
"mockery/mockery": "^1.5",
|
||||
"php-parallel-lint/php-console-highlighter": "^1.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3",
|
||||
"phpcsstandards/phpcsutils": "^1.0.0-rc1",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpstan/extension-installer": "^1.2",
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"phpstan/phpstan-mockery": "^1.1",
|
||||
"phpstan/phpstan-phpunit": "^1.3",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"psalm/plugin-mockery": "^1.1",
|
||||
"psalm/plugin-phpunit": "^0.18.4",
|
||||
"ramsey/coding-standard": "^2.0.3",
|
||||
"ramsey/conventional-commits": "^1.3",
|
||||
"vimeo/psalm": "^5.4"
|
||||
},
|
||||
"time": "2022-12-27T19:12:24+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"captainhook": {
|
||||
"force-install": true
|
||||
},
|
||||
"ramsey/conventional-commits": {
|
||||
"configFile": "conventional-commits.json"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Ramsey\\Collection\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ben Ramsey",
|
||||
"email": "ben@benramsey.com",
|
||||
"homepage": "https://benramsey.com"
|
||||
}
|
||||
],
|
||||
"description": "A PHP library for representing and manipulating collections.",
|
||||
"keywords": [
|
||||
"array",
|
||||
"collection",
|
||||
"hash",
|
||||
"map",
|
||||
"queue",
|
||||
"set"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ramsey/collection/issues",
|
||||
"source": "https://github.com/ramsey/collection/tree/1.3.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/ramsey",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/ramsey/collection",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"install-path": "../ramsey/collection"
|
||||
},
|
||||
{
|
||||
"name": "ramsey/uuid",
|
||||
"version": "4.7.5",
|
||||
"version_normalized": "4.7.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ramsey/uuid.git",
|
||||
"reference": "5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ramsey/uuid/zipball/5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e",
|
||||
"reference": "5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11",
|
||||
"ext-json": "*",
|
||||
"php": "^8.0",
|
||||
"ramsey/collection": "^1.2 || ^2.0"
|
||||
},
|
||||
"replace": {
|
||||
"rhumsaa/uuid": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"captainhook/captainhook": "^5.10",
|
||||
"captainhook/plugin-composer": "^5.3",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"doctrine/annotations": "^1.8",
|
||||
"ergebnis/composer-normalize": "^2.15",
|
||||
"mockery/mockery": "^1.3",
|
||||
"paragonie/random-lib": "^2",
|
||||
"php-mock/php-mock": "^2.2",
|
||||
"php-mock/php-mock-mockery": "^1.3",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.1",
|
||||
"phpbench/phpbench": "^1.0",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"phpstan/phpstan-mockery": "^1.1",
|
||||
"phpstan/phpstan-phpunit": "^1.1",
|
||||
"phpunit/phpunit": "^8.5 || ^9",
|
||||
"ramsey/composer-repl": "^1.4",
|
||||
"slevomat/coding-standard": "^8.4",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"vimeo/psalm": "^4.9"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.",
|
||||
"ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.",
|
||||
"ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.",
|
||||
"paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
|
||||
"ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
|
||||
},
|
||||
"time": "2023-11-08T05:53:05+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"captainhook": {
|
||||
"force-install": true
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Ramsey\\Uuid\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "A PHP library for generating and working with universally unique identifiers (UUIDs).",
|
||||
"keywords": [
|
||||
"guid",
|
||||
"identifier",
|
||||
"uuid"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ramsey/uuid/issues",
|
||||
"source": "https://github.com/ramsey/uuid/tree/4.7.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/ramsey",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/ramsey/uuid",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"install-path": "../ramsey/uuid"
|
||||
},
|
||||
{
|
||||
"name": "respect/stringifier",
|
||||
"version": "0.2.0",
|
||||
@ -4644,6 +4844,59 @@
|
||||
],
|
||||
"install-path": "../symfony/var-exporter"
|
||||
},
|
||||
{
|
||||
"name": "tekintian/phpqrcode",
|
||||
"version": "1.1.0",
|
||||
"version_normalized": "1.1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tekintian/phpqrcode.git",
|
||||
"reference": "8bc8c1189981a5dbd0d7a50fd6db4899834beff9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tekintian/phpqrcode/zipball/8bc8c1189981a5dbd0d7a50fd6db4899834beff9",
|
||||
"reference": "8bc8c1189981a5dbd0d7a50fd6db4899834beff9",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.3|^7.0|^8.0"
|
||||
},
|
||||
"time": "2023-11-06T12:08:32+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"tekintian\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"description": "支持PHP5.3至php8.2的 qrcode 二维码工具类 改进版本,支持自定义LOGO,自定义输出目录和自定义返回类型 图片,base64图片数据, 二维码图片自定义,静态方法调用,方便快捷,高效,简洁的PHP二维码生成工具",
|
||||
"homepage": "https://github.com/tekintian/phpqrcode",
|
||||
"keywords": [
|
||||
"PHP二维码",
|
||||
"php qrcode with logo",
|
||||
"phpqrcode",
|
||||
"qrcode",
|
||||
"tiny qrcode",
|
||||
"二维码工具"
|
||||
],
|
||||
"support": {
|
||||
"forum": "https://github.com/tekintian/phpqrcode",
|
||||
"issues": "https://github.com/tekintian/phpqrcode/issues",
|
||||
"source": "https://github.com/tekintian/phpqrcode"
|
||||
},
|
||||
"install-path": "../tekintian/phpqrcode"
|
||||
},
|
||||
{
|
||||
"name": "vlucas/phpdotenv",
|
||||
"version": "v5.6.0",
|
||||
|
37
vendor/composer/installed.php
vendored
37
vendor/composer/installed.php
vendored
@ -3,7 +3,7 @@
|
||||
'name' => 'workerman/webman',
|
||||
'pretty_version' => 'dev-main',
|
||||
'version' => 'dev-main',
|
||||
'reference' => 'd78b38e80f348db25511c37191ce154edc7ea094',
|
||||
'reference' => '357735ee221907da9e1391477bfe0311ae53b41c',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@ -420,6 +420,24 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'ramsey/collection' => array(
|
||||
'pretty_version' => '1.3.0',
|
||||
'version' => '1.3.0.0',
|
||||
'reference' => 'ad7475d1c9e70b190ecffc58f2d989416af339b4',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../ramsey/collection',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'ramsey/uuid' => array(
|
||||
'pretty_version' => '4.7.5',
|
||||
'version' => '4.7.5.0',
|
||||
'reference' => '5f0df49ae5ad6efb7afa69e6bfab4e5b1e080d8e',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../ramsey/uuid',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'respect/stringifier' => array(
|
||||
'pretty_version' => '0.2.0',
|
||||
'version' => '0.2.0.0',
|
||||
@ -429,6 +447,12 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'rhumsaa/uuid' => array(
|
||||
'dev_requirement' => false,
|
||||
'replaced' => array(
|
||||
0 => '4.7.5',
|
||||
),
|
||||
),
|
||||
'robmorgan/phinx' => array(
|
||||
'pretty_version' => '0.14.0',
|
||||
'version' => '0.14.0.0',
|
||||
@ -612,6 +636,15 @@
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'tekintian/phpqrcode' => array(
|
||||
'pretty_version' => '1.1.0',
|
||||
'version' => '1.1.0.0',
|
||||
'reference' => '8bc8c1189981a5dbd0d7a50fd6db4899834beff9',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../tekintian/phpqrcode',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'vlucas/phpdotenv' => array(
|
||||
'pretty_version' => 'v5.6.0',
|
||||
'version' => '5.6.0.0',
|
||||
@ -669,7 +702,7 @@
|
||||
'workerman/webman' => array(
|
||||
'pretty_version' => 'dev-main',
|
||||
'version' => 'dev-main',
|
||||
'reference' => 'd78b38e80f348db25511c37191ce154edc7ea094',
|
||||
'reference' => '357735ee221907da9e1391477bfe0311ae53b41c',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
19
vendor/ramsey/collection/LICENSE
vendored
Normal file
19
vendor/ramsey/collection/LICENSE
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2015-2022 Ben Ramsey <ben@benramsey.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
70
vendor/ramsey/collection/README.md
vendored
Normal file
70
vendor/ramsey/collection/README.md
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
<h1 align="center">ramsey/collection</h1>
|
||||
|
||||
<p align="center">
|
||||
<strong>A PHP library for representing and manipulating collections.</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/ramsey/collection"><img src="http://img.shields.io/badge/source-ramsey/collection-blue.svg?style=flat-square" alt="Source Code"></a>
|
||||
<a href="https://packagist.org/packages/ramsey/collection"><img src="https://img.shields.io/packagist/v/ramsey/collection.svg?style=flat-square&label=release" alt="Download Package"></a>
|
||||
<a href="https://php.net"><img src="https://img.shields.io/packagist/php-v/ramsey/collection.svg?style=flat-square&colorB=%238892BF" alt="PHP Programming Language"></a>
|
||||
<a href="https://github.com/ramsey/collection/blob/master/LICENSE"><img src="https://img.shields.io/packagist/l/ramsey/collection.svg?style=flat-square&colorB=darkcyan" alt="Read License"></a>
|
||||
<a href="https://github.com/ramsey/collection/actions/workflows/continuous-integration.yml"><img src="https://img.shields.io/github/actions/workflow/status/ramsey/collection/continuous-integration.yml?branch=main&logo=github&style=flat-square" alt="Build Status"></a>
|
||||
<a href="https://codecov.io/gh/ramsey/collection"><img src="https://img.shields.io/codecov/c/gh/ramsey/collection?label=codecov&logo=codecov&style=flat-square" alt="Codecov Code Coverage"></a>
|
||||
<a href="https://shepherd.dev/github/ramsey/collection"><img src="https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fshepherd.dev%2Fgithub%2Framsey%2Fcollection%2Fcoverage" alt="Psalm Type Coverage"></a>
|
||||
</p>
|
||||
|
||||
## About
|
||||
|
||||
ramsey/collection is a PHP library for representing and manipulating collections.
|
||||
|
||||
Much inspiration for this library came from the [Java Collections Framework][java].
|
||||
|
||||
This project adheres to a [code of conduct](CODE_OF_CONDUCT.md).
|
||||
By participating in this project and its community, you are expected to
|
||||
uphold this code.
|
||||
|
||||
## Installation
|
||||
|
||||
Install this package as a dependency using [Composer](https://getcomposer.org).
|
||||
|
||||
``` bash
|
||||
composer require ramsey/collection
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Examples of how to use this library may be found in the
|
||||
[Wiki pages](https://github.com/ramsey/collection/wiki/Examples).
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! To contribute, please familiarize yourself with
|
||||
[CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
|
||||
## Coordinated Disclosure
|
||||
|
||||
Keeping user information safe and secure is a top priority, and we welcome the
|
||||
contribution of external security researchers. If you believe you've found a
|
||||
security issue in software that is maintained in this repository, please read
|
||||
[SECURITY.md][] for instructions on submitting a vulnerability report.
|
||||
|
||||
## ramsey/collection for Enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of ramsey/collection and thousands of other packages are working
|
||||
with Tidelift to deliver commercial support and maintenance for the open source
|
||||
packages you use to build your applications. Save time, reduce risk, and improve
|
||||
code health, while paying the maintainers of the exact packages you use.
|
||||
[Learn more.](https://tidelift.com/subscription/pkg/packagist-ramsey-collection?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
## Copyright and License
|
||||
|
||||
The ramsey/collection library is copyright © [Ben Ramsey](https://benramsey.com)
|
||||
and licensed for use under the terms of the
|
||||
MIT License (MIT). Please see [LICENSE](LICENSE) for more information.
|
||||
|
||||
|
||||
[java]: http://docs.oracle.com/javase/8/docs/technotes/guides/collections/index.html
|
||||
[security.md]: https://github.com/ramsey/collection/blob/main/SECURITY.md
|
169
vendor/ramsey/collection/SECURITY.md
vendored
Normal file
169
vendor/ramsey/collection/SECURITY.md
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
<!--
|
||||
This policy template was created using the HackerOne Policy Builder [1],
|
||||
with guidance from the National Telecommunications and Information
|
||||
Administration Coordinated Vulnerability Disclosure Template [2].
|
||||
-->
|
||||
|
||||
# Vulnerability Disclosure Policy (VDP)
|
||||
|
||||
## Brand Promise
|
||||
|
||||
<!--
|
||||
This is your brand promise. Its objective is to "demonstrate a clear, good
|
||||
faith commitment to customers and other stakeholders potentially impacted by
|
||||
security vulnerabilities" [2].
|
||||
-->
|
||||
|
||||
Keeping user information safe and secure is a top priority, and we welcome the
|
||||
contribution of external security researchers.
|
||||
|
||||
## Scope
|
||||
|
||||
<!--
|
||||
This is your initial scope. It tells vulnerability finders and reporters
|
||||
"which systems and capabilities are 'fair game' versus 'off limits'" [2].
|
||||
For software packages, this is often a list of currently maintained versions
|
||||
of the package.
|
||||
-->
|
||||
|
||||
If you believe you've found a security issue in software that is maintained in
|
||||
this repository, we encourage you to notify us.
|
||||
|
||||
| Version | In scope | Source code |
|
||||
| ------- | :------: | ----------- |
|
||||
| latest | ✅ | https://github.com/ramsey/collection |
|
||||
|
||||
## How to Submit a Report
|
||||
|
||||
<!--
|
||||
This is your communication process. It tells security researchers how to
|
||||
contact you to report a vulnerability. It may be a link to a web form that
|
||||
uses HTTPS for secure communication, or it may be an email address.
|
||||
Optionally, you may choose to include a PGP public key, so that researchers
|
||||
may send you encrypted messages.
|
||||
-->
|
||||
|
||||
To submit a vulnerability report, please contact us at security@ramsey.dev.
|
||||
Your submission will be reviewed and validated by a member of our team.
|
||||
|
||||
## Safe Harbor
|
||||
|
||||
<!--
|
||||
This section assures vulnerability finders and reporters that they will
|
||||
receive good faith responses to their good faith acts. In other words,
|
||||
"we will not take legal action if..." [2].
|
||||
-->
|
||||
|
||||
We support safe harbor for security researchers who:
|
||||
|
||||
* Make a good faith effort to avoid privacy violations, destruction of data, and
|
||||
interruption or degradation of our services.
|
||||
* Only interact with accounts you own or with explicit permission of the account
|
||||
holder. If you do encounter Personally Identifiable Information (PII) contact
|
||||
us immediately, do not proceed with access, and immediately purge any local
|
||||
information.
|
||||
* Provide us with a reasonable amount of time to resolve vulnerabilities prior
|
||||
to any disclosure to the public or a third party.
|
||||
|
||||
We will consider activities conducted consistent with this policy to constitute
|
||||
"authorized" conduct and will not pursue civil action or initiate a complaint to
|
||||
law enforcement. We will help to the extent we can if legal action is initiated
|
||||
by a third party against you.
|
||||
|
||||
Please submit a report to us before engaging in conduct that may be inconsistent
|
||||
with or unaddressed by this policy.
|
||||
|
||||
## Preferences
|
||||
|
||||
<!--
|
||||
The preferences section sets expectations based on priority and submission
|
||||
volume, rather than legal objection or restriction [2].
|
||||
|
||||
According to the NTIA [2]:
|
||||
|
||||
This section is a living document that sets expectations for preferences
|
||||
and priorities, typically maintained by the support and engineering
|
||||
team. This can outline classes of vulnerabilities, reporting style
|
||||
(crash dumps, CVSS scoring, proof-of-concept, etc.), tools, etc. Too
|
||||
many preferences can set the wrong tone or make reporting findings
|
||||
difficult to navigate. This section also sets expectations to the
|
||||
researcher community for what types of issues are considered important
|
||||
or not.
|
||||
-->
|
||||
|
||||
* Please provide detailed reports with reproducible steps and a clearly defined
|
||||
impact.
|
||||
* Include the version number of the vulnerable package in your report
|
||||
* Social engineering (e.g. phishing, vishing, smishing) is prohibited.
|
||||
|
||||
<!--
|
||||
References
|
||||
|
||||
[1] HackerOne. Policy builder. Retrieved from https://hackerone.com/policy-builder/
|
||||
|
||||
[2] NTIA Safety Working Group. 2016. "Early stage" coordinated vulnerability
|
||||
disclosure template: Version 1.1. (15 December 2016). Retrieved from
|
||||
https://www.ntia.doc.gov/files/ntia/publications/ntia_vuln_disclosure_early_stage_template.pdf
|
||||
-->
|
||||
|
||||
## Encryption Key for security@ramsey.dev
|
||||
|
||||
For increased privacy when reporting sensitive issues, you may encrypt your
|
||||
message using the following public key:
|
||||
|
||||
```
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQINBF+Z9gEBEACbT/pIx8RR0K18t8Z2rDnmEV44YdT7HNsMdq+D6SAlx8UUb6AU
|
||||
jGIbV9dgBgGNtOLU1pxloaJwL9bWIRbj+X/Qb2WNIP//Vz1Y40ox1dSpfCUrizXx
|
||||
kb4p58Xml0PsB8dg3b4RDUgKwGC37ne5xmDnigyJPbiB2XJ6Xc46oPCjh86XROTK
|
||||
wEBB2lY67ClBlSlvC2V9KmbTboRQkLdQDhOaUosMb99zRb0EWqDLaFkZVjY5HI7i
|
||||
0pTveE6dI12NfHhTwKjZ5pUiAZQGlKA6J1dMjY2unxHZkQj5MlMfrLSyJHZxccdJ
|
||||
xD94T6OTcTHt/XmMpI2AObpewZDdChDQmcYDZXGfAhFoJmbvXsmLMGXKgzKoZ/ls
|
||||
RmLsQhh7+/r8E+Pn5r+A6Hh4uAc14ApyEP0ckKeIXw1C6pepHM4E8TEXVr/IA6K/
|
||||
z6jlHORixIFX7iNOnfHh+qwOgZw40D6JnBfEzjFi+T2Cy+JzN2uy7I8UnecTMGo3
|
||||
5t6astPy6xcH6kZYzFTV7XERR6LIIVyLAiMFd8kF5MbJ8N5ElRFsFHPW+82N2HDX
|
||||
c60iSaTB85k6R6xd8JIKDiaKE4sSuw2wHFCKq33d/GamYezp1wO+bVUQg88efljC
|
||||
2JNFyD+vl30josqhw1HcmbE1TP3DlYeIL5jQOlxCMsgai6JtTfHFM/5MYwARAQAB
|
||||
tBNzZWN1cml0eUByYW1zZXkuZGV2iQJUBBMBCAA+FiEE4drPD+/ofZ570fAYq0bv
|
||||
vXQCywIFAl+Z9gECGwMFCQeGH4AFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQ
|
||||
q0bvvXQCywIkEA//Qcwv8MtTCy01LHZd9c7VslwhNdXQDYymcTyjcYw8x7O22m4B
|
||||
3hXE6vqAplFhVxxkqXB2ef0tQuzxhPHNJgkCE4Wq4i+V6qGpaSVHQT2W6DN/NIhL
|
||||
vS8OdScc6zddmIbIkSrzVVAtjwehFNEIrX3DnbbbK+Iku7vsKT5EclOluIsjlYoX
|
||||
goW8IeReyDBqOe2H3hoCGw6EA0D/NYV2bJnfy53rXVIyarsXXeOLp7eNEH6Td7aW
|
||||
PVSrMZJe1t+knrEGnEdrXWzlg4lCJJCtemGv+pKBUomnyISXSdqyoRCCzvQjqyig
|
||||
2kRebUX8BXPW33p4OXPj9sIboUOjZwormWwqqbFMO+J4TiVCUoEoheI7emPFRcNN
|
||||
QtPJrjbY1++OznBc0GRpfeUkGoU1cbRl1bnepnFIZMTDLkrVW6I1Y4q8ZVwX3BkE
|
||||
N81ctFrRpHBlU36EdHvjPQmGtuiL77Qq3fWmMv7yTvK1wHJAXfEb0ZJWHZCbck3w
|
||||
l0CVq0Z+UUAOM8Rp1N0N8m92xtapav0qCFU9qzf2J5qX6GRmWv+d29wPgFHzDWBm
|
||||
nnrYYIA4wJLx00U6SMcVBSnNe91B+RfGY5XQhbWPjQQecOGCSDsxaFAq2MeOVJyZ
|
||||
bIjLYfG9GxoLKr5R7oLRJvZI4nKKBc1Kci/crZbdiSdQhSQGlDz88F1OHeCIdQQQ
|
||||
EQgAHRYhBOhdAxHd+lus86YQ57Atl5icjAcbBQJfmfdIAAoJELAtl5icjAcbFVcA
|
||||
/1LqB3ZjsnXDAvvAXZVjSPqofSlpMLeRQP6IM/A9Odq0AQCZrtZc1knOMGEcjppK
|
||||
Rk+sy/R0Mshy8TDuaZIRgh2Ux7kCDQRfmfYBARAAmchKzzVz7IaEq7PnZDb3szQs
|
||||
T/+E9F3m39yOpV4fEB1YzObonFakXNT7Gw2tZEx0eitUMqQ/13jjfu3UdzlKl2bR
|
||||
qA8LrSQRhB+PTC9A1XvwxCUYhhjGiLzJ9CZL6hBQB43qHOmE9XJPme90geLsF+gK
|
||||
u39Waj1SNWzwGg+Gy1Gl5f2AJoDTxznreCuFGj+Vfaczt/hlfgqpOdb9jsmdoE7t
|
||||
3DSWppA9dRHWwQSgE6J28rR4QySBcqyXS6IMykqaJn7Z26yNIaITLnHCZOSY8zhP
|
||||
ha7GFsN549EOCgECbrnPt9dmI2+hQE0RO0e7SOBNsIf5sz/i7urhwuj0CbOqhjc2
|
||||
X1AEVNFCVcb6HPi/AWefdFCRu0gaWQxn5g+9nkq5slEgvzCCiKYzaBIcr8qR6Hb4
|
||||
FaOPVPxO8vndRouq57Ws8XpAwbPttioFuCqF4u9K+tK/8e2/R8QgRYJsE3Cz/Fu8
|
||||
+pZFpMnqbDEbK3DL3ss+1ed1sky+mDV8qXXeI33XW5hMFnk1JWshUjHNlQmE6ftC
|
||||
U0xSTMVUtwJhzH2zDp8lEdu7qi3EsNULOl68ozDr6soWAvCbHPeTdTOnFySGCleG
|
||||
/3TonsoZJs/sSPPJnxFQ1DtgQL6EbhIwa0ZwU4eKYVHZ9tjxuMX3teFzRvOrJjgs
|
||||
+ywGlsIURtEckT5Y6nMAEQEAAYkCPAQYAQgAJhYhBOHazw/v6H2ee9HwGKtG7710
|
||||
AssCBQJfmfYBAhsMBQkHhh+AAAoJEKtG7710AssC8NcP/iDAcy1aZFvkA0EbZ85p
|
||||
i7/+ywtE/1wF4U4/9OuLcoskqGGnl1pJNPooMOSBCfreoTB8HimT0Fln0CoaOm4Q
|
||||
pScNq39JXmf4VxauqUJVARByP6zUfgYarqoaZNeuFF0S4AZJ2HhGzaQPjDz1uKVM
|
||||
PE6tQSgQkFzdZ9AtRA4vElTH6yRAgmepUsOihk0b0gUtVnwtRYZ8e0Qt3ie97a73
|
||||
DxLgAgedFRUbLRYiT0vNaYbainBsLWKpN/T8odwIg/smP0Khjp/ckV60cZTdBiPR
|
||||
szBTPJESMUTu0VPntc4gWwGsmhZJg/Tt/qP08XYo3VxNYBegyuWwNR66zDWvwvGH
|
||||
muMv5UchuDxp6Rt3JkIO4voMT1JSjWy9p8krkPEE4V6PxAagLjdZSkt92wVLiK5x
|
||||
y5gNrtPhU45YdRAKHr36OvJBJQ42CDaZ6nzrzghcIp9CZ7ANHrI+QLRM/csz+AGA
|
||||
szSp6S4mc1lnxxfbOhPPpebZPn0nIAXoZnnoVKdrxBVedPQHT59ZFvKTQ9Fs7gd3
|
||||
sYNuc7tJGFGC2CxBH4ANDpOQkc5q9JJ1HSGrXU3juxIiRgfA26Q22S9c71dXjElw
|
||||
Ri584QH+bL6kkYmm8xpKF6TVwhwu5xx/jBPrbWqFrtbvLNrnfPoapTihBfdIhkT6
|
||||
nmgawbBHA02D5xEqB5SU3WJu
|
||||
=eJNx
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
```
|
120
vendor/ramsey/collection/composer.json
vendored
Normal file
120
vendor/ramsey/collection/composer.json
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
{
|
||||
"name": "ramsey/collection",
|
||||
"description": "A PHP library for representing and manipulating collections.",
|
||||
"license": "MIT",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"array",
|
||||
"collection",
|
||||
"hash",
|
||||
"map",
|
||||
"queue",
|
||||
"set"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ben Ramsey",
|
||||
"email": "ben@benramsey.com",
|
||||
"homepage": "https://benramsey.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0",
|
||||
"symfony/polyfill-php81": "^1.23"
|
||||
},
|
||||
"require-dev": {
|
||||
"captainhook/plugin-composer": "^5.3",
|
||||
"ergebnis/composer-normalize": "^2.28.3",
|
||||
"fakerphp/faker": "^1.21",
|
||||
"hamcrest/hamcrest-php": "^2.0",
|
||||
"jangregor/phpstan-prophecy": "^1.0",
|
||||
"mockery/mockery": "^1.5",
|
||||
"php-parallel-lint/php-console-highlighter": "^1.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3",
|
||||
"phpcsstandards/phpcsutils": "^1.0.0-rc1",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpstan/extension-installer": "^1.2",
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"phpstan/phpstan-mockery": "^1.1",
|
||||
"phpstan/phpstan-phpunit": "^1.3",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"psalm/plugin-mockery": "^1.1",
|
||||
"psalm/plugin-phpunit": "^0.18.4",
|
||||
"ramsey/coding-standard": "^2.0.3",
|
||||
"ramsey/conventional-commits": "^1.3",
|
||||
"vimeo/psalm": "^5.4"
|
||||
},
|
||||
"minimum-stability": "RC",
|
||||
"prefer-stable": true,
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Ramsey\\Collection\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Ramsey\\Collection\\Test\\": "tests/",
|
||||
"Ramsey\\Test\\Generics\\": "tests/generics/"
|
||||
},
|
||||
"files": [
|
||||
"vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest.php"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"ergebnis/composer-normalize": true,
|
||||
"phpstan/extension-installer": true,
|
||||
"captainhook/plugin-composer": true
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
"extra": {
|
||||
"captainhook": {
|
||||
"force-install": true
|
||||
},
|
||||
"ramsey/conventional-commits": {
|
||||
"configFile": "conventional-commits.json"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev:analyze": [
|
||||
"@dev:analyze:phpstan",
|
||||
"@dev:analyze:psalm"
|
||||
],
|
||||
"dev:analyze:phpstan": "phpstan analyse --ansi --memory-limit=1G",
|
||||
"dev:analyze:psalm": "psalm",
|
||||
"dev:build:clean": "git clean -fX build/",
|
||||
"dev:lint": [
|
||||
"@dev:lint:syntax",
|
||||
"@dev:lint:style"
|
||||
],
|
||||
"dev:lint:fix": "phpcbf",
|
||||
"dev:lint:style": "phpcs --colors",
|
||||
"dev:lint:syntax": "parallel-lint --colors src/ tests/",
|
||||
"dev:test": [
|
||||
"@dev:lint",
|
||||
"@dev:analyze",
|
||||
"@dev:test:unit"
|
||||
],
|
||||
"dev:test:coverage:ci": "phpunit --colors=always --coverage-text --coverage-clover build/coverage/clover.xml --coverage-cobertura build/coverage/cobertura.xml --coverage-crap4j build/coverage/crap4j.xml --coverage-xml build/coverage/coverage-xml --log-junit build/junit.xml",
|
||||
"dev:test:coverage:html": "phpunit --colors=always --coverage-html build/coverage/coverage-html/",
|
||||
"dev:test:unit": "phpunit --colors=always",
|
||||
"test": "@dev:test"
|
||||
},
|
||||
"scripts-descriptions": {
|
||||
"dev:analyze": "Runs all static analysis checks.",
|
||||
"dev:analyze:phpstan": "Runs the PHPStan static analyzer.",
|
||||
"dev:analyze:psalm": "Runs the Psalm static analyzer.",
|
||||
"dev:build:clean": "Cleans the build/ directory.",
|
||||
"dev:lint": "Runs all linting checks.",
|
||||
"dev:lint:fix": "Auto-fixes coding standards issues, if possible.",
|
||||
"dev:lint:style": "Checks for coding standards issues.",
|
||||
"dev:lint:syntax": "Checks for syntax errors.",
|
||||
"dev:test": "Runs linting, static analysis, and unit tests.",
|
||||
"dev:test:coverage:ci": "Runs unit tests and generates CI coverage reports.",
|
||||
"dev:test:coverage:html": "Runs unit tests and generates HTML coverage report.",
|
||||
"dev:test:unit": "Runs unit tests.",
|
||||
"test": "Runs linting, static analysis, and unit tests."
|
||||
}
|
||||
}
|
22
vendor/ramsey/collection/conventional-commits.json
vendored
Normal file
22
vendor/ramsey/collection/conventional-commits.json
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"typeCase": "kebab",
|
||||
"types": [
|
||||
"chore",
|
||||
"ci",
|
||||
"docs",
|
||||
"feat",
|
||||
"fix",
|
||||
"refactor",
|
||||
"security",
|
||||
"style",
|
||||
"test"
|
||||
],
|
||||
"scopeCase": "kebab",
|
||||
"scopeRequired": false,
|
||||
"scopes": [],
|
||||
"descriptionCase": null,
|
||||
"descriptionEndMark": "",
|
||||
"bodyRequired": false,
|
||||
"bodyWrapWidth": 72,
|
||||
"requiredFooters": []
|
||||
}
|
208
vendor/ramsey/collection/src/AbstractArray.php
vendored
Normal file
208
vendor/ramsey/collection/src/AbstractArray.php
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
use ArrayIterator;
|
||||
use Traversable;
|
||||
|
||||
use function count;
|
||||
use function serialize;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* This class provides a basic implementation of `ArrayInterface`, to minimize
|
||||
* the effort required to implement this interface.
|
||||
*
|
||||
* @template T
|
||||
* @implements ArrayInterface<T>
|
||||
*/
|
||||
abstract class AbstractArray implements ArrayInterface
|
||||
{
|
||||
/**
|
||||
* The items of this array.
|
||||
*
|
||||
* @var array<array-key, T>
|
||||
*/
|
||||
protected array $data = [];
|
||||
|
||||
/**
|
||||
* Constructs a new array object.
|
||||
*
|
||||
* @param array<array-key, T> $data The initial items to add to this array.
|
||||
*/
|
||||
public function __construct(array $data = [])
|
||||
{
|
||||
// Invoke offsetSet() for each value added; in this way, sub-classes
|
||||
// may provide additional logic about values added to the array object.
|
||||
foreach ($data as $key => $value) {
|
||||
$this[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator for this array.
|
||||
*
|
||||
* @link http://php.net/manual/en/iteratoraggregate.getiterator.php IteratorAggregate::getIterator()
|
||||
*
|
||||
* @return Traversable<array-key, T>
|
||||
*/
|
||||
public function getIterator(): Traversable
|
||||
{
|
||||
return new ArrayIterator($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the given offset exists in this array.
|
||||
*
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetexists.php ArrayAccess::offsetExists()
|
||||
*
|
||||
* @param array-key $offset The offset to check.
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->data[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the specified offset.
|
||||
*
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetget.php ArrayAccess::offsetGet()
|
||||
*
|
||||
* @param array-key $offset The offset for which a value should be returned.
|
||||
*
|
||||
* @return T|null the value stored at the offset, or null if the offset
|
||||
* does not exist.
|
||||
*/
|
||||
#[\ReturnTypeWillChange] // phpcs:ignore
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->data[$offset] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given value to the given offset in the array.
|
||||
*
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetset.php ArrayAccess::offsetSet()
|
||||
*
|
||||
* @param array-key|null $offset The offset to set. If `null`, the value may be
|
||||
* set at a numerically-indexed offset.
|
||||
* @param T $value The value to set at the given offset.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
if ($offset === null) {
|
||||
$this->data[] = $value;
|
||||
} else {
|
||||
$this->data[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given offset and its value from the array.
|
||||
*
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetunset.php ArrayAccess::offsetUnset()
|
||||
*
|
||||
* @param array-key $offset The offset to remove from the array.
|
||||
*/
|
||||
public function offsetUnset($offset): void
|
||||
{
|
||||
unset($this->data[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a serialized string representation of this array object.
|
||||
*
|
||||
* @deprecated The Serializable interface will go away in PHP 9.
|
||||
*
|
||||
* @link http://php.net/manual/en/serializable.serialize.php Serializable::serialize()
|
||||
*
|
||||
* @return string a PHP serialized string.
|
||||
*/
|
||||
public function serialize(): string
|
||||
{
|
||||
return serialize($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data suitable for PHP serialization.
|
||||
*
|
||||
* @link https://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.serialize
|
||||
* @link https://www.php.net/serialize
|
||||
*
|
||||
* @return array<array-key, T>
|
||||
*/
|
||||
public function __serialize(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a serialized string representation into an instance object.
|
||||
*
|
||||
* @deprecated The Serializable interface will go away in PHP 9.
|
||||
*
|
||||
* @link http://php.net/manual/en/serializable.unserialize.php Serializable::unserialize()
|
||||
*
|
||||
* @param string $serialized A PHP serialized string to unserialize.
|
||||
*
|
||||
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
*/
|
||||
public function unserialize($serialized): void
|
||||
{
|
||||
/** @var array<array-key, T> $data */
|
||||
$data = unserialize($serialized, ['allowed_classes' => false]);
|
||||
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds unserialized data to the object.
|
||||
*
|
||||
* @param array<array-key, T> $data
|
||||
*/
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of items in this array.
|
||||
*
|
||||
* @link http://php.net/manual/en/countable.count.php Countable::count()
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->data);
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return count($this->data) === 0;
|
||||
}
|
||||
}
|
341
vendor/ramsey/collection/src/AbstractCollection.php
vendored
Normal file
341
vendor/ramsey/collection/src/AbstractCollection.php
vendored
Normal file
@ -0,0 +1,341 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
use Closure;
|
||||
use Ramsey\Collection\Exception\CollectionMismatchException;
|
||||
use Ramsey\Collection\Exception\InvalidArgumentException;
|
||||
use Ramsey\Collection\Exception\InvalidSortOrderException;
|
||||
use Ramsey\Collection\Exception\OutOfBoundsException;
|
||||
use Ramsey\Collection\Tool\TypeTrait;
|
||||
use Ramsey\Collection\Tool\ValueExtractorTrait;
|
||||
use Ramsey\Collection\Tool\ValueToStringTrait;
|
||||
|
||||
use function array_filter;
|
||||
use function array_map;
|
||||
use function array_merge;
|
||||
use function array_search;
|
||||
use function array_udiff;
|
||||
use function array_uintersect;
|
||||
use function current;
|
||||
use function end;
|
||||
use function in_array;
|
||||
use function is_int;
|
||||
use function is_object;
|
||||
use function reset;
|
||||
use function spl_object_id;
|
||||
use function sprintf;
|
||||
use function unserialize;
|
||||
use function usort;
|
||||
|
||||
/**
|
||||
* This class provides a basic implementation of `CollectionInterface`, to
|
||||
* minimize the effort required to implement this interface
|
||||
*
|
||||
* @template T
|
||||
* @extends AbstractArray<T>
|
||||
* @implements CollectionInterface<T>
|
||||
*/
|
||||
abstract class AbstractCollection extends AbstractArray implements CollectionInterface
|
||||
{
|
||||
use TypeTrait;
|
||||
use ValueToStringTrait;
|
||||
use ValueExtractorTrait;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function add($element): bool
|
||||
{
|
||||
$this[] = $element;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function contains($element, bool $strict = true): bool
|
||||
{
|
||||
return in_array($element, $this->data, $strict);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
if ($this->checkType($this->getType(), $value) === false) {
|
||||
throw new InvalidArgumentException(
|
||||
'Value must be of type ' . $this->getType() . '; value is '
|
||||
. $this->toolValueToString($value),
|
||||
);
|
||||
}
|
||||
|
||||
if ($offset === null) {
|
||||
$this->data[] = $value;
|
||||
} else {
|
||||
$this->data[$offset] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function remove($element): bool
|
||||
{
|
||||
if (($position = array_search($element, $this->data, true)) !== false) {
|
||||
unset($this[$position]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function column(string $propertyOrMethod): array
|
||||
{
|
||||
$temp = [];
|
||||
|
||||
foreach ($this->data as $item) {
|
||||
/** @var mixed $value */
|
||||
$value = $this->extractValue($item, $propertyOrMethod);
|
||||
|
||||
/** @psalm-suppress MixedAssignment */
|
||||
$temp[] = $value;
|
||||
}
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function first()
|
||||
{
|
||||
if ($this->isEmpty()) {
|
||||
throw new OutOfBoundsException('Can\'t determine first item. Collection is empty');
|
||||
}
|
||||
|
||||
reset($this->data);
|
||||
|
||||
/** @var T $first */
|
||||
$first = current($this->data);
|
||||
|
||||
return $first;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function last()
|
||||
{
|
||||
if ($this->isEmpty()) {
|
||||
throw new OutOfBoundsException('Can\'t determine last item. Collection is empty');
|
||||
}
|
||||
|
||||
/** @var T $item */
|
||||
$item = end($this->data);
|
||||
reset($this->data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public function sort(string $propertyOrMethod, string $order = self::SORT_ASC): CollectionInterface
|
||||
{
|
||||
if (!in_array($order, [self::SORT_ASC, self::SORT_DESC], true)) {
|
||||
throw new InvalidSortOrderException('Invalid sort order given: ' . $order);
|
||||
}
|
||||
|
||||
$collection = clone $this;
|
||||
|
||||
usort(
|
||||
$collection->data,
|
||||
/**
|
||||
* @param T $a
|
||||
* @param T $b
|
||||
*/
|
||||
function ($a, $b) use ($propertyOrMethod, $order): int {
|
||||
/** @var mixed $aValue */
|
||||
$aValue = $this->extractValue($a, $propertyOrMethod);
|
||||
|
||||
/** @var mixed $bValue */
|
||||
$bValue = $this->extractValue($b, $propertyOrMethod);
|
||||
|
||||
return ($aValue <=> $bValue) * ($order === self::SORT_DESC ? -1 : 1);
|
||||
},
|
||||
);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function filter(callable $callback): CollectionInterface
|
||||
{
|
||||
$collection = clone $this;
|
||||
$collection->data = array_merge([], array_filter($collection->data, $callback));
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function where(string $propertyOrMethod, $value): CollectionInterface
|
||||
{
|
||||
return $this->filter(function ($item) use ($propertyOrMethod, $value) {
|
||||
/** @var mixed $accessorValue */
|
||||
$accessorValue = $this->extractValue($item, $propertyOrMethod);
|
||||
|
||||
return $accessorValue === $value;
|
||||
});
|
||||
}
|
||||
|
||||
public function map(callable $callback): CollectionInterface
|
||||
{
|
||||
return new Collection('mixed', array_map($callback, $this->data));
|
||||
}
|
||||
|
||||
public function diff(CollectionInterface $other): CollectionInterface
|
||||
{
|
||||
$this->compareCollectionTypes($other);
|
||||
|
||||
$diffAtoB = array_udiff($this->data, $other->toArray(), $this->getComparator());
|
||||
$diffBtoA = array_udiff($other->toArray(), $this->data, $this->getComparator());
|
||||
|
||||
/** @var array<array-key, T> $diff */
|
||||
$diff = array_merge($diffAtoB, $diffBtoA);
|
||||
|
||||
$collection = clone $this;
|
||||
$collection->data = $diff;
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function intersect(CollectionInterface $other): CollectionInterface
|
||||
{
|
||||
$this->compareCollectionTypes($other);
|
||||
|
||||
/** @var array<array-key, T> $intersect */
|
||||
$intersect = array_uintersect($this->data, $other->toArray(), $this->getComparator());
|
||||
|
||||
$collection = clone $this;
|
||||
$collection->data = $intersect;
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function merge(CollectionInterface ...$collections): CollectionInterface
|
||||
{
|
||||
$mergedCollection = clone $this;
|
||||
|
||||
foreach ($collections as $index => $collection) {
|
||||
if (!$collection instanceof static) {
|
||||
throw new CollectionMismatchException(
|
||||
sprintf('Collection with index %d must be of type %s', $index, static::class),
|
||||
);
|
||||
}
|
||||
|
||||
// When using generics (Collection.php, Set.php, etc),
|
||||
// we also need to make sure that the internal types match each other
|
||||
if ($this->getUniformType($collection) !== $this->getUniformType($this)) {
|
||||
throw new CollectionMismatchException(
|
||||
sprintf(
|
||||
'Collection items in collection with index %d must be of type %s',
|
||||
$index,
|
||||
$this->getType(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($collection as $key => $value) {
|
||||
if (is_int($key)) {
|
||||
$mergedCollection[] = $value;
|
||||
} else {
|
||||
$mergedCollection[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $mergedCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function unserialize($serialized): void
|
||||
{
|
||||
/** @var array<array-key, T> $data */
|
||||
$data = unserialize($serialized, ['allowed_classes' => [$this->getType()]]);
|
||||
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CollectionInterface<T> $other
|
||||
*/
|
||||
private function compareCollectionTypes(CollectionInterface $other): void
|
||||
{
|
||||
if (!$other instanceof static) {
|
||||
throw new CollectionMismatchException('Collection must be of type ' . static::class);
|
||||
}
|
||||
|
||||
// When using generics (Collection.php, Set.php, etc),
|
||||
// we also need to make sure that the internal types match each other
|
||||
if ($this->getUniformType($other) !== $this->getUniformType($this)) {
|
||||
throw new CollectionMismatchException('Collection items must be of type ' . $this->getType());
|
||||
}
|
||||
}
|
||||
|
||||
private function getComparator(): Closure
|
||||
{
|
||||
return /**
|
||||
* @param T $a
|
||||
* @param T $b
|
||||
*/
|
||||
function ($a, $b): int {
|
||||
// If the two values are object, we convert them to unique scalars.
|
||||
// If the collection contains mixed values (unlikely) where some are objects
|
||||
// and some are not, we leave them as they are.
|
||||
// The comparator should still work and the result of $a < $b should
|
||||
// be consistent but unpredictable since not documented.
|
||||
if (is_object($a) && is_object($b)) {
|
||||
$a = spl_object_id($a);
|
||||
$b = spl_object_id($b);
|
||||
}
|
||||
|
||||
return $a === $b ? 0 : ($a < $b ? 1 : -1);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CollectionInterface<mixed> $collection
|
||||
*/
|
||||
private function getUniformType(CollectionInterface $collection): string
|
||||
{
|
||||
switch ($collection->getType()) {
|
||||
case 'integer':
|
||||
return 'int';
|
||||
case 'boolean':
|
||||
return 'bool';
|
||||
case 'double':
|
||||
return 'float';
|
||||
default:
|
||||
return $collection->getType();
|
||||
}
|
||||
}
|
||||
}
|
50
vendor/ramsey/collection/src/AbstractSet.php
vendored
Normal file
50
vendor/ramsey/collection/src/AbstractSet.php
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
/**
|
||||
* This class contains the basic implementation of a collection that does not
|
||||
* allow duplicated values (a set), to minimize the effort required to implement
|
||||
* this specific type of collection.
|
||||
*
|
||||
* @template T
|
||||
* @extends AbstractCollection<T>
|
||||
*/
|
||||
abstract class AbstractSet extends AbstractCollection
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function add($element): bool
|
||||
{
|
||||
if ($this->contains($element)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::add($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
if ($this->contains($value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
parent::offsetSet($offset, $value);
|
||||
}
|
||||
}
|
51
vendor/ramsey/collection/src/ArrayInterface.php
vendored
Normal file
51
vendor/ramsey/collection/src/ArrayInterface.php
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use IteratorAggregate;
|
||||
use Serializable;
|
||||
|
||||
/**
|
||||
* `ArrayInterface` provides traversable array functionality to data types.
|
||||
*
|
||||
* @template T
|
||||
* @extends ArrayAccess<array-key, T>
|
||||
* @extends IteratorAggregate<array-key, T>
|
||||
*/
|
||||
interface ArrayInterface extends
|
||||
ArrayAccess,
|
||||
Countable,
|
||||
IteratorAggregate,
|
||||
Serializable
|
||||
{
|
||||
/**
|
||||
* Removes all items from this array.
|
||||
*/
|
||||
public function clear(): void;
|
||||
|
||||
/**
|
||||
* Returns a native PHP array representation of this array object.
|
||||
*
|
||||
* @return array<array-key, T>
|
||||
*/
|
||||
public function toArray(): array;
|
||||
|
||||
/**
|
||||
* Returns `true` if this array is empty.
|
||||
*/
|
||||
public function isEmpty(): bool;
|
||||
}
|
104
vendor/ramsey/collection/src/Collection.php
vendored
Normal file
104
vendor/ramsey/collection/src/Collection.php
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
/**
|
||||
* A collection represents a group of objects.
|
||||
*
|
||||
* Each object in the collection is of a specific, defined type.
|
||||
*
|
||||
* This is a direct implementation of `CollectionInterface`, provided for
|
||||
* the sake of convenience.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ``` php
|
||||
* $collection = new \Ramsey\Collection\Collection('My\\Foo');
|
||||
* $collection->add(new \My\Foo());
|
||||
* $collection->add(new \My\Foo());
|
||||
*
|
||||
* foreach ($collection as $foo) {
|
||||
* // Do something with $foo
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* It is preferable to subclass `AbstractCollection` to create your own typed
|
||||
* collections. For example:
|
||||
*
|
||||
* ``` php
|
||||
* namespace My\Foo;
|
||||
*
|
||||
* class FooCollection extends \Ramsey\Collection\AbstractCollection
|
||||
* {
|
||||
* public function getType()
|
||||
* {
|
||||
* return 'My\\Foo';
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* And then use it similarly to the earlier example:
|
||||
*
|
||||
* ``` php
|
||||
* $fooCollection = new \My\Foo\FooCollection();
|
||||
* $fooCollection->add(new \My\Foo());
|
||||
* $fooCollection->add(new \My\Foo());
|
||||
*
|
||||
* foreach ($fooCollection as $foo) {
|
||||
* // Do something with $foo
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The benefit with this approach is that you may do type-checking on the
|
||||
* collection object:
|
||||
*
|
||||
* ``` php
|
||||
* if ($collection instanceof \My\Foo\FooCollection) {
|
||||
* // the collection is a collection of My\Foo objects
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @template T
|
||||
* @extends AbstractCollection<T>
|
||||
*/
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
/**
|
||||
* The type of elements stored in this collection.
|
||||
*
|
||||
* A collection's type is immutable once it is set. For this reason, this
|
||||
* property is set private.
|
||||
*/
|
||||
private string $collectionType;
|
||||
|
||||
/**
|
||||
* Constructs a collection object of the specified type, optionally with the
|
||||
* specified data.
|
||||
*
|
||||
* @param string $collectionType The type (FQCN) associated with this
|
||||
* collection.
|
||||
* @param array<array-key, T> $data The initial items to store in the collection.
|
||||
*/
|
||||
public function __construct(string $collectionType, array $data = [])
|
||||
{
|
||||
$this->collectionType = $collectionType;
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->collectionType;
|
||||
}
|
||||
}
|
206
vendor/ramsey/collection/src/CollectionInterface.php
vendored
Normal file
206
vendor/ramsey/collection/src/CollectionInterface.php
vendored
Normal file
@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
/**
|
||||
* A collection represents a group of objects, known as its elements.
|
||||
*
|
||||
* Some collections allow duplicate elements and others do not. Some are ordered
|
||||
* and others unordered.
|
||||
*
|
||||
* @template T
|
||||
* @extends ArrayInterface<T>
|
||||
*/
|
||||
interface CollectionInterface extends ArrayInterface
|
||||
{
|
||||
/**
|
||||
* Ascending sort type.
|
||||
*/
|
||||
public const SORT_ASC = 'asc';
|
||||
|
||||
/**
|
||||
* Descending sort type.
|
||||
*/
|
||||
public const SORT_DESC = 'desc';
|
||||
|
||||
/**
|
||||
* Ensures that this collection contains the specified element (optional
|
||||
* operation).
|
||||
*
|
||||
* Returns `true` if this collection changed as a result of the call.
|
||||
* (Returns `false` if this collection does not permit duplicates and
|
||||
* already contains the specified element.)
|
||||
*
|
||||
* Collections that support this operation may place limitations on what
|
||||
* elements may be added to this collection. In particular, some
|
||||
* collections will refuse to add `null` elements, and others will impose
|
||||
* restrictions on the type of elements that may be added. Collection
|
||||
* classes should clearly specify in their documentation any restrictions
|
||||
* on what elements may be added.
|
||||
*
|
||||
* If a collection refuses to add a particular element for any reason other
|
||||
* than that it already contains the element, it must throw an exception
|
||||
* (rather than returning `false`). This preserves the invariant that a
|
||||
* collection always contains the specified element after this call returns.
|
||||
*
|
||||
* @param T $element The element to add to the collection.
|
||||
*
|
||||
* @return bool `true` if this collection changed as a result of the call.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function add($element): bool;
|
||||
|
||||
/**
|
||||
* Returns `true` if this collection contains the specified element.
|
||||
*
|
||||
* @param T $element The element to check whether the collection contains.
|
||||
* @param bool $strict Whether to perform a strict type check on the value.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function contains($element, bool $strict = true): bool;
|
||||
|
||||
/**
|
||||
* Returns the type associated with this collection.
|
||||
*/
|
||||
public function getType(): string;
|
||||
|
||||
/**
|
||||
* Removes a single instance of the specified element from this collection,
|
||||
* if it is present.
|
||||
*
|
||||
* @param T $element The element to remove from the collection.
|
||||
*
|
||||
* @return bool `true` if an element was removed as a result of this call.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function remove($element): bool;
|
||||
|
||||
/**
|
||||
* Returns the values from the given property or method.
|
||||
*
|
||||
* @param string $propertyOrMethod The property or method name to filter by.
|
||||
*
|
||||
* @return list<mixed>
|
||||
*/
|
||||
public function column(string $propertyOrMethod): array;
|
||||
|
||||
/**
|
||||
* Returns the first item of the collection.
|
||||
*
|
||||
* @return T
|
||||
*/
|
||||
public function first();
|
||||
|
||||
/**
|
||||
* Returns the last item of the collection.
|
||||
*
|
||||
* @return T
|
||||
*/
|
||||
public function last();
|
||||
|
||||
/**
|
||||
* Sort the collection by a property or method with the given sort order.
|
||||
*
|
||||
* This will always leave the original collection untouched and will return
|
||||
* a new one.
|
||||
*
|
||||
* @param string $propertyOrMethod The property or method to sort by.
|
||||
* @param string $order The sort order for the resulting collection (one of
|
||||
* this interface's `SORT_*` constants).
|
||||
*
|
||||
* @return CollectionInterface<T>
|
||||
*/
|
||||
public function sort(string $propertyOrMethod, string $order = self::SORT_ASC): self;
|
||||
|
||||
/**
|
||||
* Filter out items of the collection which don't match the criteria of
|
||||
* given callback.
|
||||
*
|
||||
* This will always leave the original collection untouched and will return
|
||||
* a new one.
|
||||
*
|
||||
* See the {@link http://php.net/manual/en/function.array-filter.php PHP array_filter() documentation}
|
||||
* for examples of how the `$callback` parameter works.
|
||||
*
|
||||
* @param callable(T):bool $callback A callable to use for filtering elements.
|
||||
*
|
||||
* @return CollectionInterface<T>
|
||||
*/
|
||||
public function filter(callable $callback): self;
|
||||
|
||||
/**
|
||||
* Create a new collection where items match the criteria of given callback.
|
||||
*
|
||||
* This will always leave the original collection untouched and will return
|
||||
* a new one.
|
||||
*
|
||||
* @param string $propertyOrMethod The property or method to evaluate.
|
||||
* @param mixed $value The value to match.
|
||||
*
|
||||
* @return CollectionInterface<T>
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function where(string $propertyOrMethod, $value): self;
|
||||
|
||||
/**
|
||||
* Apply a given callback method on each item of the collection.
|
||||
*
|
||||
* This will always leave the original collection untouched. The new
|
||||
* collection is created by mapping the callback to each item of the
|
||||
* original collection.
|
||||
*
|
||||
* See the {@link http://php.net/manual/en/function.array-map.php PHP array_map() documentation}
|
||||
* for examples of how the `$callback` parameter works.
|
||||
*
|
||||
* @param callable(T):TCallbackReturn $callback A callable to apply to each
|
||||
* item of the collection.
|
||||
*
|
||||
* @return CollectionInterface<TCallbackReturn>
|
||||
*
|
||||
* @template TCallbackReturn
|
||||
*/
|
||||
public function map(callable $callback): self;
|
||||
|
||||
/**
|
||||
* Create a new collection with divergent items between current and given
|
||||
* collection.
|
||||
*
|
||||
* @param CollectionInterface<T> $other The collection to check for divergent
|
||||
* items.
|
||||
*
|
||||
* @return CollectionInterface<T>
|
||||
*/
|
||||
public function diff(CollectionInterface $other): self;
|
||||
|
||||
/**
|
||||
* Create a new collection with intersecting item between current and given
|
||||
* collection.
|
||||
*
|
||||
* @param CollectionInterface<T> $other The collection to check for
|
||||
* intersecting items.
|
||||
*
|
||||
* @return CollectionInterface<T>
|
||||
*/
|
||||
public function intersect(CollectionInterface $other): self;
|
||||
|
||||
/**
|
||||
* Merge current items and items of given collections into a new one.
|
||||
*
|
||||
* @param CollectionInterface<T> ...$collections The collections to merge.
|
||||
*
|
||||
* @return CollectionInterface<T>
|
||||
*/
|
||||
public function merge(CollectionInterface ...$collections): self;
|
||||
}
|
187
vendor/ramsey/collection/src/DoubleEndedQueue.php
vendored
Normal file
187
vendor/ramsey/collection/src/DoubleEndedQueue.php
vendored
Normal file
@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
use Ramsey\Collection\Exception\InvalidArgumentException;
|
||||
use Ramsey\Collection\Exception\NoSuchElementException;
|
||||
|
||||
/**
|
||||
* This class provides a basic implementation of `DoubleEndedQueueInterface`, to
|
||||
* minimize the effort required to implement this interface.
|
||||
*
|
||||
* @template T
|
||||
* @extends Queue<T>
|
||||
* @implements DoubleEndedQueueInterface<T>
|
||||
*/
|
||||
class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
|
||||
{
|
||||
/**
|
||||
* Index of the last element in the queue.
|
||||
*/
|
||||
private int $tail = -1;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
if ($this->checkType($this->getType(), $value) === false) {
|
||||
throw new InvalidArgumentException(
|
||||
'Value must be of type ' . $this->getType() . '; value is '
|
||||
. $this->toolValueToString($value),
|
||||
);
|
||||
}
|
||||
|
||||
$this->tail++;
|
||||
|
||||
$this->data[$this->tail] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidArgumentException if $element is of the wrong type
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addFirst($element): bool
|
||||
{
|
||||
if ($this->checkType($this->getType(), $element) === false) {
|
||||
throw new InvalidArgumentException(
|
||||
'Value must be of type ' . $this->getType() . '; value is '
|
||||
. $this->toolValueToString($element),
|
||||
);
|
||||
}
|
||||
|
||||
$this->index--;
|
||||
|
||||
$this->data[$this->index] = $element;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addLast($element): bool
|
||||
{
|
||||
return $this->add($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function offerFirst($element): bool
|
||||
{
|
||||
try {
|
||||
return $this->addFirst($element);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function offerLast($element): bool
|
||||
{
|
||||
return $this->offer($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function removeFirst()
|
||||
{
|
||||
return $this->remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function removeLast()
|
||||
{
|
||||
$tail = $this->pollLast();
|
||||
|
||||
if ($tail === null) {
|
||||
throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.');
|
||||
}
|
||||
|
||||
return $tail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function pollFirst()
|
||||
{
|
||||
return $this->poll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function pollLast()
|
||||
{
|
||||
if ($this->count() === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$tail = $this[$this->tail];
|
||||
|
||||
unset($this[$this->tail]);
|
||||
$this->tail--;
|
||||
|
||||
return $tail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function firstElement()
|
||||
{
|
||||
return $this->element();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function lastElement()
|
||||
{
|
||||
if ($this->count() === 0) {
|
||||
throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.');
|
||||
}
|
||||
|
||||
return $this->data[$this->tail];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function peekFirst()
|
||||
{
|
||||
return $this->peek();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function peekLast()
|
||||
{
|
||||
if ($this->count() === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->data[$this->tail];
|
||||
}
|
||||
}
|
317
vendor/ramsey/collection/src/DoubleEndedQueueInterface.php
vendored
Normal file
317
vendor/ramsey/collection/src/DoubleEndedQueueInterface.php
vendored
Normal file
@ -0,0 +1,317 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
use Ramsey\Collection\Exception\NoSuchElementException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* A linear collection that supports element insertion and removal at both ends.
|
||||
*
|
||||
* Most `DoubleEndedQueueInterface` implementations place no fixed limits on the
|
||||
* number of elements they may contain, but this interface supports
|
||||
* capacity-restricted double-ended queues as well as those with no fixed size
|
||||
* limit.
|
||||
*
|
||||
* This interface defines methods to access the elements at both ends of the
|
||||
* double-ended queue. Methods are provided to insert, remove, and examine the
|
||||
* element. Each of these methods exists in two forms: one throws an exception
|
||||
* if the operation fails, the other returns a special value (either `null` or
|
||||
* `false`, depending on the operation). The latter form of the insert operation
|
||||
* is designed specifically for use with capacity-restricted implementations; in
|
||||
* most implementations, insert operations cannot fail.
|
||||
*
|
||||
* The twelve methods described above are summarized in the following table:
|
||||
*
|
||||
* <table>
|
||||
* <caption>Summary of DoubleEndedQueueInterface methods</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <th></th>
|
||||
* <th colspan=2>First Element (Head)</th>
|
||||
* <th colspan=2>Last Element (Tail)</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td></td>
|
||||
* <td><em>Throws exception</em></td>
|
||||
* <td><em>Special value</em></td>
|
||||
* <td><em>Throws exception</em></td>
|
||||
* <td><em>Special value</em></td>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <th>Insert</th>
|
||||
* <td><code>addFirst()</code></td>
|
||||
* <td><code>offerFirst()</code></td>
|
||||
* <td><code>addLast()</code></td>
|
||||
* <td><code>offerLast()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th>Remove</th>
|
||||
* <td><code>removeFirst()</code></td>
|
||||
* <td><code>pollFirst()</code></td>
|
||||
* <td><code>removeLast()</code></td>
|
||||
* <td><code>pollLast()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th>Examine</th>
|
||||
* <td><code>firstElement()</code></td>
|
||||
* <td><code>peekFirst()</code></td>
|
||||
* <td><code>lastElement()</code></td>
|
||||
* <td><code>peekLast()</code></td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
*
|
||||
* This interface extends the `QueueInterface`. When a double-ended queue is
|
||||
* used as a queue, FIFO (first-in-first-out) behavior results. Elements are
|
||||
* added at the end of the double-ended queue and removed from the beginning.
|
||||
* The methods inherited from the `QueueInterface` are precisely equivalent to
|
||||
* `DoubleEndedQueueInterface` methods as indicated in the following table:
|
||||
*
|
||||
* <table>
|
||||
* <caption>Comparison of QueueInterface and DoubleEndedQueueInterface methods</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <th>QueueInterface Method</th>
|
||||
* <th>DoubleEndedQueueInterface Method</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <td><code>add()</code></td>
|
||||
* <td><code>addLast()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><code>offer()</code></td>
|
||||
* <td><code>offerLast()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><code>remove()</code></td>
|
||||
* <td><code>removeFirst()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><code>poll()</code></td>
|
||||
* <td><code>pollFirst()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><code>element()</code></td>
|
||||
* <td><code>firstElement()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><code>peek()</code></td>
|
||||
* <td><code>peekFirst()</code></td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
*
|
||||
* Double-ended queues can also be used as LIFO (last-in-first-out) stacks. When
|
||||
* a double-ended queue is used as a stack, elements are pushed and popped from
|
||||
* the beginning of the double-ended queue. Stack concepts are precisely
|
||||
* equivalent to `DoubleEndedQueueInterface` methods as indicated in the table
|
||||
* below:
|
||||
*
|
||||
* <table>
|
||||
* <caption>Comparison of stack concepts and DoubleEndedQueueInterface methods</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <th>Stack concept</th>
|
||||
* <th>DoubleEndedQueueInterface Method</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <td><em>push</em></td>
|
||||
* <td><code>addFirst()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><em>pop</em></td>
|
||||
* <td><code>removeFirst()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><em>peek</em></td>
|
||||
* <td><code>peekFirst()</code></td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
*
|
||||
* Note that the `peek()` method works equally well when a double-ended queue is
|
||||
* used as a queue or a stack; in either case, elements are drawn from the
|
||||
* beginning of the double-ended queue.
|
||||
*
|
||||
* While `DoubleEndedQueueInterface` implementations are not strictly required
|
||||
* to prohibit the insertion of `null` elements, they are strongly encouraged to
|
||||
* do so. Users of any `DoubleEndedQueueInterface` implementations that do allow
|
||||
* `null` elements are strongly encouraged *not* to take advantage of the
|
||||
* ability to insert nulls. This is so because `null` is used as a special
|
||||
* return value by various methods to indicated that the double-ended queue is
|
||||
* empty.
|
||||
*
|
||||
* @template T
|
||||
* @extends QueueInterface<T>
|
||||
*/
|
||||
interface DoubleEndedQueueInterface extends QueueInterface
|
||||
{
|
||||
/**
|
||||
* Inserts the specified element at the front of this queue if it is
|
||||
* possible to do so immediately without violating capacity restrictions.
|
||||
*
|
||||
* When using a capacity-restricted double-ended queue, it is generally
|
||||
* preferable to use the `offerFirst()` method.
|
||||
*
|
||||
* @param T $element The element to add to the front of this queue.
|
||||
*
|
||||
* @return bool `true` if this queue changed as a result of the call.
|
||||
*
|
||||
* @throws RuntimeException if a queue refuses to add a particular element
|
||||
* for any reason other than that it already contains the element.
|
||||
* Implementations should use a more-specific exception that extends
|
||||
* `\RuntimeException`.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function addFirst($element): bool;
|
||||
|
||||
/**
|
||||
* Inserts the specified element at the end of this queue if it is possible
|
||||
* to do so immediately without violating capacity restrictions.
|
||||
*
|
||||
* When using a capacity-restricted double-ended queue, it is generally
|
||||
* preferable to use the `offerLast()` method.
|
||||
*
|
||||
* This method is equivalent to `add()`.
|
||||
*
|
||||
* @param T $element The element to add to the end of this queue.
|
||||
*
|
||||
* @return bool `true` if this queue changed as a result of the call.
|
||||
*
|
||||
* @throws RuntimeException if a queue refuses to add a particular element
|
||||
* for any reason other than that it already contains the element.
|
||||
* Implementations should use a more-specific exception that extends
|
||||
* `\RuntimeException`.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function addLast($element): bool;
|
||||
|
||||
/**
|
||||
* Inserts the specified element at the front of this queue if it is
|
||||
* possible to do so immediately without violating capacity restrictions.
|
||||
*
|
||||
* When using a capacity-restricted queue, this method is generally
|
||||
* preferable to `addFirst()`, which can fail to insert an element only by
|
||||
* throwing an exception.
|
||||
*
|
||||
* @param T $element The element to add to the front of this queue.
|
||||
*
|
||||
* @return bool `true` if the element was added to this queue, else `false`.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function offerFirst($element): bool;
|
||||
|
||||
/**
|
||||
* Inserts the specified element at the end of this queue if it is possible
|
||||
* to do so immediately without violating capacity restrictions.
|
||||
*
|
||||
* When using a capacity-restricted queue, this method is generally
|
||||
* preferable to `addLast()` which can fail to insert an element only by
|
||||
* throwing an exception.
|
||||
*
|
||||
* @param T $element The element to add to the end of this queue.
|
||||
*
|
||||
* @return bool `true` if the element was added to this queue, else `false`.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function offerLast($element): bool;
|
||||
|
||||
/**
|
||||
* Retrieves and removes the head of this queue.
|
||||
*
|
||||
* This method differs from `pollFirst()` only in that it throws an
|
||||
* exception if this queue is empty.
|
||||
*
|
||||
* @return T the first element in this queue.
|
||||
*
|
||||
* @throws NoSuchElementException if this queue is empty.
|
||||
*/
|
||||
public function removeFirst();
|
||||
|
||||
/**
|
||||
* Retrieves and removes the tail of this queue.
|
||||
*
|
||||
* This method differs from `pollLast()` only in that it throws an exception
|
||||
* if this queue is empty.
|
||||
*
|
||||
* @return T the last element in this queue.
|
||||
*
|
||||
* @throws NoSuchElementException if this queue is empty.
|
||||
*/
|
||||
public function removeLast();
|
||||
|
||||
/**
|
||||
* Retrieves and removes the head of this queue, or returns `null` if this
|
||||
* queue is empty.
|
||||
*
|
||||
* @return T|null the head of this queue, or `null` if this queue is empty.
|
||||
*/
|
||||
public function pollFirst();
|
||||
|
||||
/**
|
||||
* Retrieves and removes the tail of this queue, or returns `null` if this
|
||||
* queue is empty.
|
||||
*
|
||||
* @return T|null the tail of this queue, or `null` if this queue is empty.
|
||||
*/
|
||||
public function pollLast();
|
||||
|
||||
/**
|
||||
* Retrieves, but does not remove, the head of this queue.
|
||||
*
|
||||
* This method differs from `peekFirst()` only in that it throws an
|
||||
* exception if this queue is empty.
|
||||
*
|
||||
* @return T the head of this queue.
|
||||
*
|
||||
* @throws NoSuchElementException if this queue is empty.
|
||||
*/
|
||||
public function firstElement();
|
||||
|
||||
/**
|
||||
* Retrieves, but does not remove, the tail of this queue.
|
||||
*
|
||||
* This method differs from `peekLast()` only in that it throws an exception
|
||||
* if this queue is empty.
|
||||
*
|
||||
* @return T the tail of this queue.
|
||||
*
|
||||
* @throws NoSuchElementException if this queue is empty.
|
||||
*/
|
||||
public function lastElement();
|
||||
|
||||
/**
|
||||
* Retrieves, but does not remove, the head of this queue, or returns `null`
|
||||
* if this queue is empty.
|
||||
*
|
||||
* @return T|null the head of this queue, or `null` if this queue is empty.
|
||||
*/
|
||||
public function peekFirst();
|
||||
|
||||
/**
|
||||
* Retrieves, but does not remove, the tail of this queue, or returns `null`
|
||||
* if this queue is empty.
|
||||
*
|
||||
* @return T|null the tail of this queue, or `null` if this queue is empty.
|
||||
*/
|
||||
public function peekLast();
|
||||
}
|
24
vendor/ramsey/collection/src/Exception/CollectionMismatchException.php
vendored
Normal file
24
vendor/ramsey/collection/src/Exception/CollectionMismatchException.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown when attempting to operate on collections of differing types.
|
||||
*/
|
||||
class CollectionMismatchException extends RuntimeException
|
||||
{
|
||||
}
|
22
vendor/ramsey/collection/src/Exception/InvalidArgumentException.php
vendored
Normal file
22
vendor/ramsey/collection/src/Exception/InvalidArgumentException.php
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate an argument is not of the expected type.
|
||||
*/
|
||||
class InvalidArgumentException extends \InvalidArgumentException
|
||||
{
|
||||
}
|
24
vendor/ramsey/collection/src/Exception/InvalidSortOrderException.php
vendored
Normal file
24
vendor/ramsey/collection/src/Exception/InvalidSortOrderException.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown when attempting to use a sort order that is not recognized.
|
||||
*/
|
||||
class InvalidSortOrderException extends RuntimeException
|
||||
{
|
||||
}
|
24
vendor/ramsey/collection/src/Exception/NoSuchElementException.php
vendored
Normal file
24
vendor/ramsey/collection/src/Exception/NoSuchElementException.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown when attempting to access an element that does not exist.
|
||||
*/
|
||||
class NoSuchElementException extends RuntimeException
|
||||
{
|
||||
}
|
22
vendor/ramsey/collection/src/Exception/OutOfBoundsException.php
vendored
Normal file
22
vendor/ramsey/collection/src/Exception/OutOfBoundsException.php
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when attempting to access an element out of the range of the collection.
|
||||
*/
|
||||
class OutOfBoundsException extends \OutOfBoundsException
|
||||
{
|
||||
}
|
24
vendor/ramsey/collection/src/Exception/UnsupportedOperationException.php
vendored
Normal file
24
vendor/ramsey/collection/src/Exception/UnsupportedOperationException.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the requested operation is not supported.
|
||||
*/
|
||||
class UnsupportedOperationException extends RuntimeException
|
||||
{
|
||||
}
|
24
vendor/ramsey/collection/src/Exception/ValueExtractionException.php
vendored
Normal file
24
vendor/ramsey/collection/src/Exception/ValueExtractionException.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown when attempting to extract a value for a method or property that does not exist.
|
||||
*/
|
||||
class ValueExtractionException extends RuntimeException
|
||||
{
|
||||
}
|
24
vendor/ramsey/collection/src/GenericArray.php
vendored
Normal file
24
vendor/ramsey/collection/src/GenericArray.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
/**
|
||||
* `GenericArray` represents a standard array object.
|
||||
*
|
||||
* @extends AbstractArray<mixed>
|
||||
*/
|
||||
class GenericArray extends AbstractArray
|
||||
{
|
||||
}
|
163
vendor/ramsey/collection/src/Map/AbstractMap.php
vendored
Normal file
163
vendor/ramsey/collection/src/Map/AbstractMap.php
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Map;
|
||||
|
||||
use Ramsey\Collection\AbstractArray;
|
||||
use Ramsey\Collection\Exception\InvalidArgumentException;
|
||||
|
||||
use function array_key_exists;
|
||||
use function array_keys;
|
||||
use function in_array;
|
||||
use function var_export;
|
||||
|
||||
/**
|
||||
* This class provides a basic implementation of `MapInterface`, to minimize the
|
||||
* effort required to implement this interface.
|
||||
*
|
||||
* @template T
|
||||
* @extends AbstractArray<T>
|
||||
* @implements MapInterface<T>
|
||||
*/
|
||||
abstract class AbstractMap extends AbstractArray implements MapInterface
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
if ($offset === null) {
|
||||
throw new InvalidArgumentException(
|
||||
'Map elements are key/value pairs; a key must be provided for '
|
||||
. 'value ' . var_export($value, true),
|
||||
);
|
||||
}
|
||||
|
||||
$this->data[$offset] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function containsKey($key): bool
|
||||
{
|
||||
return array_key_exists($key, $this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function containsValue($value): bool
|
||||
{
|
||||
return in_array($value, $this->data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function keys(): array
|
||||
{
|
||||
return array_keys($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function get($key, $defaultValue = null)
|
||||
{
|
||||
if (!$this->containsKey($key)) {
|
||||
return $defaultValue;
|
||||
}
|
||||
|
||||
return $this[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function put($key, $value)
|
||||
{
|
||||
$previousValue = $this->get($key);
|
||||
$this[$key] = $value;
|
||||
|
||||
return $previousValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function putIfAbsent($key, $value)
|
||||
{
|
||||
$currentValue = $this->get($key);
|
||||
|
||||
if ($currentValue === null) {
|
||||
$this[$key] = $value;
|
||||
}
|
||||
|
||||
return $currentValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function remove($key)
|
||||
{
|
||||
$previousValue = $this->get($key);
|
||||
unset($this[$key]);
|
||||
|
||||
return $previousValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function removeIf($key, $value): bool
|
||||
{
|
||||
if ($this->get($key) === $value) {
|
||||
unset($this[$key]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function replace($key, $value)
|
||||
{
|
||||
$currentValue = $this->get($key);
|
||||
|
||||
if ($this->containsKey($key)) {
|
||||
$this[$key] = $value;
|
||||
}
|
||||
|
||||
return $currentValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function replaceIf($key, $oldValue, $newValue): bool
|
||||
{
|
||||
if ($this->get($key) === $oldValue) {
|
||||
$this[$key] = $newValue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
68
vendor/ramsey/collection/src/Map/AbstractTypedMap.php
vendored
Normal file
68
vendor/ramsey/collection/src/Map/AbstractTypedMap.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Map;
|
||||
|
||||
use Ramsey\Collection\Exception\InvalidArgumentException;
|
||||
use Ramsey\Collection\Tool\TypeTrait;
|
||||
use Ramsey\Collection\Tool\ValueToStringTrait;
|
||||
|
||||
use function var_export;
|
||||
|
||||
/**
|
||||
* This class provides a basic implementation of `TypedMapInterface`, to
|
||||
* minimize the effort required to implement this interface.
|
||||
*
|
||||
* @template K of array-key
|
||||
* @template T
|
||||
* @extends AbstractMap<T>
|
||||
* @implements TypedMapInterface<T>
|
||||
*/
|
||||
abstract class AbstractTypedMap extends AbstractMap implements TypedMapInterface
|
||||
{
|
||||
use TypeTrait;
|
||||
use ValueToStringTrait;
|
||||
|
||||
/**
|
||||
* @param K|null $offset
|
||||
* @param T $value
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
if ($offset === null) {
|
||||
throw new InvalidArgumentException(
|
||||
'Map elements are key/value pairs; a key must be provided for '
|
||||
. 'value ' . var_export($value, true),
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->checkType($this->getKeyType(), $offset) === false) {
|
||||
throw new InvalidArgumentException(
|
||||
'Key must be of type ' . $this->getKeyType() . '; key is '
|
||||
. $this->toolValueToString($offset),
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->checkType($this->getValueType(), $value) === false) {
|
||||
throw new InvalidArgumentException(
|
||||
'Value must be of type ' . $this->getValueType() . '; value is '
|
||||
. $this->toolValueToString($value),
|
||||
);
|
||||
}
|
||||
|
||||
parent::offsetSet($offset, $value);
|
||||
}
|
||||
}
|
25
vendor/ramsey/collection/src/Map/AssociativeArrayMap.php
vendored
Normal file
25
vendor/ramsey/collection/src/Map/AssociativeArrayMap.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Map;
|
||||
|
||||
/**
|
||||
* `AssociativeArrayMap` represents a standard associative array object.
|
||||
*
|
||||
* @template T
|
||||
* @extends AbstractMap<T>
|
||||
*/
|
||||
class AssociativeArrayMap extends AbstractMap
|
||||
{
|
||||
}
|
149
vendor/ramsey/collection/src/Map/MapInterface.php
vendored
Normal file
149
vendor/ramsey/collection/src/Map/MapInterface.php
vendored
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Map;
|
||||
|
||||
use Ramsey\Collection\ArrayInterface;
|
||||
|
||||
/**
|
||||
* An object that maps keys to values.
|
||||
*
|
||||
* A map cannot contain duplicate keys; each key can map to at most one value.
|
||||
*
|
||||
* @template T
|
||||
* @extends ArrayInterface<T>
|
||||
*/
|
||||
interface MapInterface extends ArrayInterface
|
||||
{
|
||||
/**
|
||||
* Returns `true` if this map contains a mapping for the specified key.
|
||||
*
|
||||
* @param array-key $key The key to check in the map.
|
||||
*/
|
||||
public function containsKey($key): bool;
|
||||
|
||||
/**
|
||||
* Returns `true` if this map maps one or more keys to the specified value.
|
||||
*
|
||||
* This performs a strict type check on the value.
|
||||
*
|
||||
* @param T $value The value to check in the map.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function containsValue($value): bool;
|
||||
|
||||
/**
|
||||
* Return an array of the keys contained in this map.
|
||||
*
|
||||
* @return list<array-key>
|
||||
*/
|
||||
public function keys(): array;
|
||||
|
||||
/**
|
||||
* Returns the value to which the specified key is mapped, `null` if this
|
||||
* map contains no mapping for the key, or (optionally) `$defaultValue` if
|
||||
* this map contains no mapping for the key.
|
||||
*
|
||||
* @param array-key $key The key to return from the map.
|
||||
* @param T|null $defaultValue The default value to use if `$key` is not found.
|
||||
*
|
||||
* @return T|null the value or `null` if the key could not be found.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function get($key, $defaultValue = null);
|
||||
|
||||
/**
|
||||
* Associates the specified value with the specified key in this map.
|
||||
*
|
||||
* If the map previously contained a mapping for the key, the old value is
|
||||
* replaced by the specified value.
|
||||
*
|
||||
* @param array-key $key The key to put or replace in the map.
|
||||
* @param T $value The value to store at `$key`.
|
||||
*
|
||||
* @return T|null the previous value associated with key, or `null` if
|
||||
* there was no mapping for `$key`.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function put($key, $value);
|
||||
|
||||
/**
|
||||
* Associates the specified value with the specified key in this map only if
|
||||
* it is not already set.
|
||||
*
|
||||
* If there is already a value associated with `$key`, this returns that
|
||||
* value without replacing it.
|
||||
*
|
||||
* @param array-key $key The key to put in the map.
|
||||
* @param T $value The value to store at `$key`.
|
||||
*
|
||||
* @return T|null the previous value associated with key, or `null` if
|
||||
* there was no mapping for `$key`.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function putIfAbsent($key, $value);
|
||||
|
||||
/**
|
||||
* Removes the mapping for a key from this map if it is present.
|
||||
*
|
||||
* @param array-key $key The key to remove from the map.
|
||||
*
|
||||
* @return T|null the previous value associated with key, or `null` if
|
||||
* there was no mapping for `$key`.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function remove($key);
|
||||
|
||||
/**
|
||||
* Removes the entry for the specified key only if it is currently mapped to
|
||||
* the specified value.
|
||||
*
|
||||
* This performs a strict type check on the value.
|
||||
*
|
||||
* @param array-key $key The key to remove from the map.
|
||||
* @param T $value The value to match.
|
||||
*
|
||||
* @return bool true if the value was removed.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function removeIf($key, $value): bool;
|
||||
|
||||
/**
|
||||
* Replaces the entry for the specified key only if it is currently mapped
|
||||
* to some value.
|
||||
*
|
||||
* @param array-key $key The key to replace.
|
||||
* @param T $value The value to set at `$key`.
|
||||
*
|
||||
* @return T|null the previous value associated with key, or `null` if
|
||||
* there was no mapping for `$key`.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function replace($key, $value);
|
||||
|
||||
/**
|
||||
* Replaces the entry for the specified key only if currently mapped to the
|
||||
* specified value.
|
||||
*
|
||||
* This performs a strict type check on the value.
|
||||
*
|
||||
* @param array-key $key The key to remove from the map.
|
||||
* @param T $oldValue The value to match.
|
||||
* @param T $newValue The value to use as a replacement.
|
||||
*
|
||||
* @return bool true if the value was replaced.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function replaceIf($key, $oldValue, $newValue): bool;
|
||||
}
|
121
vendor/ramsey/collection/src/Map/NamedParameterMap.php
vendored
Normal file
121
vendor/ramsey/collection/src/Map/NamedParameterMap.php
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Map;
|
||||
|
||||
use Ramsey\Collection\Exception\InvalidArgumentException;
|
||||
use Ramsey\Collection\Tool\TypeTrait;
|
||||
use Ramsey\Collection\Tool\ValueToStringTrait;
|
||||
|
||||
use function array_combine;
|
||||
use function array_key_exists;
|
||||
use function is_int;
|
||||
use function var_export;
|
||||
|
||||
/**
|
||||
* `NamedParameterMap` represents a mapping of values to a set of named keys
|
||||
* that may optionally be typed
|
||||
*
|
||||
* @extends AbstractMap<mixed>
|
||||
*/
|
||||
class NamedParameterMap extends AbstractMap
|
||||
{
|
||||
use TypeTrait;
|
||||
use ValueToStringTrait;
|
||||
|
||||
/**
|
||||
* Named parameters defined for this map.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected array $namedParameters;
|
||||
|
||||
/**
|
||||
* Constructs a new `NamedParameterMap`.
|
||||
*
|
||||
* @param array<array-key, string> $namedParameters The named parameters defined for this map.
|
||||
* @param array<array-key, mixed> $data An initial set of data to set on this map.
|
||||
*/
|
||||
public function __construct(array $namedParameters, array $data = [])
|
||||
{
|
||||
$this->namedParameters = $this->filterNamedParameters($namedParameters);
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns named parameters set for this `NamedParameterMap`.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getNamedParameters(): array
|
||||
{
|
||||
return $this->namedParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
if ($offset === null) {
|
||||
throw new InvalidArgumentException(
|
||||
'Map elements are key/value pairs; a key must be provided for '
|
||||
. 'value ' . var_export($value, true),
|
||||
);
|
||||
}
|
||||
|
||||
if (!array_key_exists($offset, $this->namedParameters)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Attempting to set value for unconfigured parameter \''
|
||||
. $offset . '\'',
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->checkType($this->namedParameters[$offset], $value) === false) {
|
||||
throw new InvalidArgumentException(
|
||||
'Value for \'' . $offset . '\' must be of type '
|
||||
. $this->namedParameters[$offset] . '; value is '
|
||||
. $this->toolValueToString($value),
|
||||
);
|
||||
}
|
||||
|
||||
$this->data[$offset] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of named parameters, constructs a proper mapping of
|
||||
* named parameters to types.
|
||||
*
|
||||
* @param array<array-key, string> $namedParameters The named parameters to filter.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function filterNamedParameters(array $namedParameters): array
|
||||
{
|
||||
$names = [];
|
||||
$types = [];
|
||||
|
||||
foreach ($namedParameters as $key => $value) {
|
||||
if (is_int($key)) {
|
||||
$names[] = $value;
|
||||
$types[] = 'mixed';
|
||||
} else {
|
||||
$names[] = $key;
|
||||
$types[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return array_combine($names, $types) ?: [];
|
||||
}
|
||||
}
|
132
vendor/ramsey/collection/src/Map/TypedMap.php
vendored
Normal file
132
vendor/ramsey/collection/src/Map/TypedMap.php
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Map;
|
||||
|
||||
use Ramsey\Collection\Tool\TypeTrait;
|
||||
|
||||
/**
|
||||
* A `TypedMap` represents a map of elements where key and value are typed.
|
||||
*
|
||||
* Each element is identified by a key with defined type and a value of defined
|
||||
* type. The keys of the map must be unique. The values on the map can be
|
||||
* repeated but each with its own different key.
|
||||
*
|
||||
* The most common case is to use a string type key, but it's not limited to
|
||||
* this type of keys.
|
||||
*
|
||||
* This is a direct implementation of `TypedMapInterface`, provided for the sake
|
||||
* of convenience.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```php
|
||||
* $map = new TypedMap('string', Foo::class);
|
||||
* $map['x'] = new Foo();
|
||||
* foreach ($map as $key => $value) {
|
||||
* // do something with $key, it will be a Foo::class
|
||||
* }
|
||||
*
|
||||
* // this will throw an exception since key must be string
|
||||
* $map[10] = new Foo();
|
||||
*
|
||||
* // this will throw an exception since value must be a Foo
|
||||
* $map['bar'] = 'bar';
|
||||
*
|
||||
* // initialize map with contents
|
||||
* $map = new TypedMap('string', Foo::class, [
|
||||
* new Foo(), new Foo(), new Foo()
|
||||
* ]);
|
||||
* ```
|
||||
*
|
||||
* It is preferable to subclass `AbstractTypedMap` to create your own typed map
|
||||
* implementation:
|
||||
*
|
||||
* ```php
|
||||
* class FooTypedMap extends AbstractTypedMap
|
||||
* {
|
||||
* public function getKeyType()
|
||||
* {
|
||||
* return 'int';
|
||||
* }
|
||||
*
|
||||
* public function getValueType()
|
||||
* {
|
||||
* return Foo::class;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* … but you also may use the `TypedMap` class:
|
||||
*
|
||||
* ```php
|
||||
* class FooTypedMap extends TypedMap
|
||||
* {
|
||||
* public function __constructor(array $data = [])
|
||||
* {
|
||||
* parent::__construct('int', Foo::class, $data);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @template K of array-key
|
||||
* @template T
|
||||
* @extends AbstractTypedMap<K, T>
|
||||
*/
|
||||
class TypedMap extends AbstractTypedMap
|
||||
{
|
||||
use TypeTrait;
|
||||
|
||||
/**
|
||||
* The data type of keys stored in this collection.
|
||||
*
|
||||
* A map key's type is immutable once it is set. For this reason, this
|
||||
* property is set private.
|
||||
*/
|
||||
private string $keyType;
|
||||
|
||||
/**
|
||||
* The data type of values stored in this collection.
|
||||
*
|
||||
* A map value's type is immutable once it is set. For this reason, this
|
||||
* property is set private.
|
||||
*/
|
||||
private string $valueType;
|
||||
|
||||
/**
|
||||
* Constructs a map object of the specified key and value types,
|
||||
* optionally with the specified data.
|
||||
*
|
||||
* @param string $keyType The data type of the map's keys.
|
||||
* @param string $valueType The data type of the map's values.
|
||||
* @param array<K, T> $data The initial data to set for this map.
|
||||
*/
|
||||
public function __construct(string $keyType, string $valueType, array $data = [])
|
||||
{
|
||||
$this->keyType = $keyType;
|
||||
$this->valueType = $valueType;
|
||||
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
public function getKeyType(): string
|
||||
{
|
||||
return $this->keyType;
|
||||
}
|
||||
|
||||
public function getValueType(): string
|
||||
{
|
||||
return $this->valueType;
|
||||
}
|
||||
}
|
35
vendor/ramsey/collection/src/Map/TypedMapInterface.php
vendored
Normal file
35
vendor/ramsey/collection/src/Map/TypedMapInterface.php
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Map;
|
||||
|
||||
/**
|
||||
* A `TypedMapInterface` represents a map of elements where key and value are
|
||||
* typed.
|
||||
*
|
||||
* @template T
|
||||
* @extends MapInterface<T>
|
||||
*/
|
||||
interface TypedMapInterface extends MapInterface
|
||||
{
|
||||
/**
|
||||
* Return the type used on the key.
|
||||
*/
|
||||
public function getKeyType(): string;
|
||||
|
||||
/**
|
||||
* Return the type forced on the values.
|
||||
*/
|
||||
public function getValueType(): string;
|
||||
}
|
169
vendor/ramsey/collection/src/Queue.php
vendored
Normal file
169
vendor/ramsey/collection/src/Queue.php
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
use Ramsey\Collection\Exception\InvalidArgumentException;
|
||||
use Ramsey\Collection\Exception\NoSuchElementException;
|
||||
use Ramsey\Collection\Tool\TypeTrait;
|
||||
use Ramsey\Collection\Tool\ValueToStringTrait;
|
||||
|
||||
/**
|
||||
* This class provides a basic implementation of `QueueInterface`, to minimize
|
||||
* the effort required to implement this interface.
|
||||
*
|
||||
* @template T
|
||||
* @extends AbstractArray<T>
|
||||
* @implements QueueInterface<T>
|
||||
*/
|
||||
class Queue extends AbstractArray implements QueueInterface
|
||||
{
|
||||
use TypeTrait;
|
||||
use ValueToStringTrait;
|
||||
|
||||
/**
|
||||
* The type of elements stored in this queue.
|
||||
*
|
||||
* A queue's type is immutable once it is set. For this reason, this
|
||||
* property is set private.
|
||||
*/
|
||||
private string $queueType;
|
||||
|
||||
/**
|
||||
* The index of the head of the queue.
|
||||
*/
|
||||
protected int $index = 0;
|
||||
|
||||
/**
|
||||
* Constructs a queue object of the specified type, optionally with the
|
||||
* specified data.
|
||||
*
|
||||
* @param string $queueType The type (FQCN) associated with this queue.
|
||||
* @param array<array-key, T> $data The initial items to store in the collection.
|
||||
*/
|
||||
public function __construct(string $queueType, array $data = [])
|
||||
{
|
||||
$this->queueType = $queueType;
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Since arbitrary offsets may not be manipulated in a queue, this method
|
||||
* serves only to fulfill the `ArrayAccess` interface requirements. It is
|
||||
* invoked by other operations when adding values to the queue.
|
||||
*
|
||||
* @throws InvalidArgumentException if $value is of the wrong type
|
||||
*/
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
if ($this->checkType($this->getType(), $value) === false) {
|
||||
throw new InvalidArgumentException(
|
||||
'Value must be of type ' . $this->getType() . '; value is '
|
||||
. $this->toolValueToString($value),
|
||||
);
|
||||
}
|
||||
|
||||
$this->data[] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidArgumentException if $value is of the wrong type
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function add($element): bool
|
||||
{
|
||||
$this[] = $element;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function element()
|
||||
{
|
||||
$element = $this->peek();
|
||||
|
||||
if ($element === null) {
|
||||
throw new NoSuchElementException(
|
||||
'Can\'t return element from Queue. Queue is empty.',
|
||||
);
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function offer($element): bool
|
||||
{
|
||||
try {
|
||||
return $this->add($element);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function peek()
|
||||
{
|
||||
if ($this->count() === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this[$this->index];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function poll()
|
||||
{
|
||||
if ($this->count() === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$head = $this[$this->index];
|
||||
|
||||
unset($this[$this->index]);
|
||||
$this->index++;
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
$head = $this->poll();
|
||||
|
||||
if ($head === null) {
|
||||
throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.');
|
||||
}
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->queueType;
|
||||
}
|
||||
}
|
204
vendor/ramsey/collection/src/QueueInterface.php
vendored
Normal file
204
vendor/ramsey/collection/src/QueueInterface.php
vendored
Normal file
@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
use Ramsey\Collection\Exception\NoSuchElementException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* A queue is a collection in which the entities in the collection are kept in
|
||||
* order.
|
||||
*
|
||||
* The principal operations on the queue are the addition of entities to the end
|
||||
* (tail), also known as *enqueue*, and removal of entities from the front
|
||||
* (head), also known as *dequeue*. This makes the queue a first-in-first-out
|
||||
* (FIFO) data structure.
|
||||
*
|
||||
* Besides basic array operations, queues provide additional insertion,
|
||||
* extraction, and inspection operations. Each of these methods exists in two
|
||||
* forms: one throws an exception if the operation fails, the other returns a
|
||||
* special value (either `null` or `false`, depending on the operation). The
|
||||
* latter form of the insert operation is designed specifically for use with
|
||||
* capacity-restricted `QueueInterface` implementations; in most
|
||||
* implementations, insert operations cannot fail.
|
||||
*
|
||||
* <table>
|
||||
* <caption>Summary of QueueInterface methods</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <td></td>
|
||||
* <td><em>Throws exception</em></td>
|
||||
* <td><em>Returns special value</em></td>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <th>Insert</th>
|
||||
* <td><code>add()</code></td>
|
||||
* <td><code>offer()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th>Remove</th>
|
||||
* <td><code>remove()</code></td>
|
||||
* <td><code>poll()</code></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <th>Examine</th>
|
||||
* <td><code>element()</code></td>
|
||||
* <td><code>peek()</code></td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
*
|
||||
* Queues typically, but do not necessarily, order elements in a FIFO
|
||||
* (first-in-first-out) manner. Among the exceptions are priority queues, which
|
||||
* order elements according to a supplied comparator, or the elements' natural
|
||||
* ordering, and LIFO queues (or stacks) which order the elements LIFO
|
||||
* (last-in-first-out). Whatever the ordering used, the head of the queue is
|
||||
* that element which would be removed by a call to remove() or poll(). In a
|
||||
* FIFO queue, all new elements are inserted at the tail of the queue. Other
|
||||
* kinds of queues may use different placement rules. Every `QueueInterface`
|
||||
* implementation must specify its ordering properties.
|
||||
*
|
||||
* The `offer()` method inserts an element if possible, otherwise returning
|
||||
* `false`. This differs from the `add()` method, which can fail to add an
|
||||
* element only by throwing an unchecked exception. The `offer()` method is
|
||||
* designed for use when failure is a normal, rather than exceptional
|
||||
* occurrence, for example, in fixed-capacity (or "bounded") queues.
|
||||
*
|
||||
* The `remove()` and `poll()` methods remove and return the head of the queue.
|
||||
* Exactly which element is removed from the queue is a function of the queue's
|
||||
* ordering policy, which differs from implementation to implementation. The
|
||||
* `remove()` and `poll()` methods differ only in their behavior when the queue
|
||||
* is empty: the `remove()` method throws an exception, while the `poll()`
|
||||
* method returns `null`.
|
||||
*
|
||||
* The `element()` and `peek()` methods return, but do not remove, the head of
|
||||
* the queue.
|
||||
*
|
||||
* `QueueInterface` implementations generally do not allow insertion of `null`
|
||||
* elements, although some implementations do not prohibit insertion of `null`.
|
||||
* Even in the implementations that permit it, `null` should not be inserted
|
||||
* into a queue, as `null` is also used as a special return value by the
|
||||
* `poll()` method to indicate that the queue contains no elements.
|
||||
*
|
||||
* @template T
|
||||
* @extends ArrayInterface<T>
|
||||
*/
|
||||
interface QueueInterface extends ArrayInterface
|
||||
{
|
||||
/**
|
||||
* Ensures that this queue contains the specified element (optional
|
||||
* operation).
|
||||
*
|
||||
* Returns `true` if this queue changed as a result of the call. (Returns
|
||||
* `false` if this queue does not permit duplicates and already contains the
|
||||
* specified element.)
|
||||
*
|
||||
* Queues that support this operation may place limitations on what elements
|
||||
* may be added to this queue. In particular, some queues will refuse to add
|
||||
* `null` elements, and others will impose restrictions on the type of
|
||||
* elements that may be added. Queue classes should clearly specify in their
|
||||
* documentation any restrictions on what elements may be added.
|
||||
*
|
||||
* If a queue refuses to add a particular element for any reason other than
|
||||
* that it already contains the element, it must throw an exception (rather
|
||||
* than returning `false`). This preserves the invariant that a queue always
|
||||
* contains the specified element after this call returns.
|
||||
*
|
||||
* @see self::offer()
|
||||
*
|
||||
* @param T $element The element to add to this queue.
|
||||
*
|
||||
* @return bool `true` if this queue changed as a result of the call.
|
||||
*
|
||||
* @throws RuntimeException if a queue refuses to add a particular element
|
||||
* for any reason other than that it already contains the element.
|
||||
* Implementations should use a more-specific exception that extends
|
||||
* `\RuntimeException`.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function add($element): bool;
|
||||
|
||||
/**
|
||||
* Retrieves, but does not remove, the head of this queue.
|
||||
*
|
||||
* This method differs from `peek()` only in that it throws an exception if
|
||||
* this queue is empty.
|
||||
*
|
||||
* @see self::peek()
|
||||
*
|
||||
* @return T the head of this queue.
|
||||
*
|
||||
* @throws NoSuchElementException if this queue is empty.
|
||||
*/
|
||||
public function element();
|
||||
|
||||
/**
|
||||
* Inserts the specified element into this queue if it is possible to do so
|
||||
* immediately without violating capacity restrictions.
|
||||
*
|
||||
* When using a capacity-restricted queue, this method is generally
|
||||
* preferable to `add()`, which can fail to insert an element only by
|
||||
* throwing an exception.
|
||||
*
|
||||
* @see self::add()
|
||||
*
|
||||
* @param T $element The element to add to this queue.
|
||||
*
|
||||
* @return bool `true` if the element was added to this queue, else `false`.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
public function offer($element): bool;
|
||||
|
||||
/**
|
||||
* Retrieves, but does not remove, the head of this queue, or returns `null`
|
||||
* if this queue is empty.
|
||||
*
|
||||
* @see self::element()
|
||||
*
|
||||
* @return T|null the head of this queue, or `null` if this queue is empty.
|
||||
*/
|
||||
public function peek();
|
||||
|
||||
/**
|
||||
* Retrieves and removes the head of this queue, or returns `null`
|
||||
* if this queue is empty.
|
||||
*
|
||||
* @see self::remove()
|
||||
*
|
||||
* @return T|null the head of this queue, or `null` if this queue is empty.
|
||||
*/
|
||||
public function poll();
|
||||
|
||||
/**
|
||||
* Retrieves and removes the head of this queue.
|
||||
*
|
||||
* This method differs from `poll()` only in that it throws an exception if
|
||||
* this queue is empty.
|
||||
*
|
||||
* @see self::poll()
|
||||
*
|
||||
* @return T the head of this queue.
|
||||
*
|
||||
* @throws NoSuchElementException if this queue is empty.
|
||||
*/
|
||||
public function remove();
|
||||
|
||||
/**
|
||||
* Returns the type associated with this queue.
|
||||
*/
|
||||
public function getType(): string;
|
||||
}
|
67
vendor/ramsey/collection/src/Set.php
vendored
Normal file
67
vendor/ramsey/collection/src/Set.php
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection;
|
||||
|
||||
/**
|
||||
* A set is a collection that contains no duplicate elements.
|
||||
*
|
||||
* Great care must be exercised if mutable objects are used as set elements.
|
||||
* The behavior of a set is not specified if the value of an object is changed
|
||||
* in a manner that affects equals comparisons while the object is an element in
|
||||
* the set.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ``` php
|
||||
* $foo = new \My\Foo();
|
||||
* $set = new Set(\My\Foo::class);
|
||||
*
|
||||
* $set->add($foo); // returns TRUE, the element don't exists
|
||||
* $set->add($foo); // returns FALSE, the element already exists
|
||||
*
|
||||
* $bar = new \My\Foo();
|
||||
* $set->add($bar); // returns TRUE, $bar !== $foo
|
||||
* ```
|
||||
*
|
||||
* @template T
|
||||
* @extends AbstractSet<T>
|
||||
*/
|
||||
class Set extends AbstractSet
|
||||
{
|
||||
/**
|
||||
* The type of elements stored in this set
|
||||
*
|
||||
* A set's type is immutable. For this reason, this property is private.
|
||||
*/
|
||||
private string $setType;
|
||||
|
||||
/**
|
||||
* Constructs a set object of the specified type, optionally with the
|
||||
* specified data.
|
||||
*
|
||||
* @param string $setType The type (FQCN) associated with this set.
|
||||
* @param array<array-key, T> $data The initial items to store in the set.
|
||||
*/
|
||||
public function __construct(string $setType, array $data = [])
|
||||
{
|
||||
$this->setType = $setType;
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->setType;
|
||||
}
|
||||
}
|
74
vendor/ramsey/collection/src/Tool/TypeTrait.php
vendored
Normal file
74
vendor/ramsey/collection/src/Tool/TypeTrait.php
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Tool;
|
||||
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_callable;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function is_numeric;
|
||||
use function is_object;
|
||||
use function is_resource;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
* Provides functionality to check values for specific types.
|
||||
*/
|
||||
trait TypeTrait
|
||||
{
|
||||
/**
|
||||
* Returns `true` if value is of the specified type.
|
||||
*
|
||||
* @param string $type The type to check the value against.
|
||||
* @param mixed $value The value to check.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
protected function checkType(string $type, $value): bool
|
||||
{
|
||||
switch ($type) {
|
||||
case 'array':
|
||||
return is_array($value);
|
||||
case 'bool':
|
||||
case 'boolean':
|
||||
return is_bool($value);
|
||||
case 'callable':
|
||||
return is_callable($value);
|
||||
case 'float':
|
||||
case 'double':
|
||||
return is_float($value);
|
||||
case 'int':
|
||||
case 'integer':
|
||||
return is_int($value);
|
||||
case 'null':
|
||||
return $value === null;
|
||||
case 'numeric':
|
||||
return is_numeric($value);
|
||||
case 'object':
|
||||
return is_object($value);
|
||||
case 'resource':
|
||||
return is_resource($value);
|
||||
case 'scalar':
|
||||
return is_scalar($value);
|
||||
case 'string':
|
||||
return is_string($value);
|
||||
case 'mixed':
|
||||
return true;
|
||||
default:
|
||||
return $value instanceof $type;
|
||||
}
|
||||
}
|
||||
}
|
61
vendor/ramsey/collection/src/Tool/ValueExtractorTrait.php
vendored
Normal file
61
vendor/ramsey/collection/src/Tool/ValueExtractorTrait.php
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Tool;
|
||||
|
||||
use Ramsey\Collection\Exception\ValueExtractionException;
|
||||
|
||||
use function get_class;
|
||||
use function is_object;
|
||||
use function method_exists;
|
||||
use function property_exists;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Provides functionality to extract the value of a property or method from an object.
|
||||
*/
|
||||
trait ValueExtractorTrait
|
||||
{
|
||||
/**
|
||||
* Extracts the value of the given property or method from the object.
|
||||
*
|
||||
* @param mixed $object The object to extract the value from.
|
||||
* @param string $propertyOrMethod The property or method for which the
|
||||
* value should be extracted.
|
||||
*
|
||||
* @return mixed the value extracted from the specified property or method.
|
||||
*
|
||||
* @throws ValueExtractionException if the method or property is not defined.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
protected function extractValue($object, string $propertyOrMethod)
|
||||
{
|
||||
if (!is_object($object)) {
|
||||
throw new ValueExtractionException('Unable to extract a value from a non-object');
|
||||
}
|
||||
|
||||
if (property_exists($object, $propertyOrMethod)) {
|
||||
return $object->$propertyOrMethod;
|
||||
}
|
||||
|
||||
if (method_exists($object, $propertyOrMethod)) {
|
||||
return $object->{$propertyOrMethod}();
|
||||
}
|
||||
|
||||
throw new ValueExtractionException(
|
||||
// phpcs:ignore SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall
|
||||
sprintf('Method or property "%s" not defined in %s', $propertyOrMethod, get_class($object)),
|
||||
);
|
||||
}
|
||||
}
|
98
vendor/ramsey/collection/src/Tool/ValueToStringTrait.php
vendored
Normal file
98
vendor/ramsey/collection/src/Tool/ValueToStringTrait.php
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/collection library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Collection\Tool;
|
||||
|
||||
use DateTimeInterface;
|
||||
|
||||
use function get_class;
|
||||
use function get_resource_type;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_callable;
|
||||
use function is_object;
|
||||
use function is_resource;
|
||||
use function is_scalar;
|
||||
use function var_export;
|
||||
|
||||
/**
|
||||
* Provides functionality to express a value as string
|
||||
*/
|
||||
trait ValueToStringTrait
|
||||
{
|
||||
/**
|
||||
* Returns a string representation of the value.
|
||||
*
|
||||
* - null value: `'NULL'`
|
||||
* - boolean: `'TRUE'`, `'FALSE'`
|
||||
* - array: `'Array'`
|
||||
* - scalar: converted-value
|
||||
* - resource: `'(type resource #number)'`
|
||||
* - object with `__toString()`: result of `__toString()`
|
||||
* - object DateTime: ISO 8601 date
|
||||
* - object: `'(className Object)'`
|
||||
* - anonymous function: same as object
|
||||
*
|
||||
* @param mixed $value the value to return as a string.
|
||||
*/
|
||||
// phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
protected function toolValueToString($value): string
|
||||
{
|
||||
// null
|
||||
if ($value === null) {
|
||||
return 'NULL';
|
||||
}
|
||||
|
||||
// boolean constants
|
||||
if (is_bool($value)) {
|
||||
return $value ? 'TRUE' : 'FALSE';
|
||||
}
|
||||
|
||||
// array
|
||||
if (is_array($value)) {
|
||||
return 'Array';
|
||||
}
|
||||
|
||||
// scalar types (integer, float, string)
|
||||
if (is_scalar($value)) {
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
// resource
|
||||
if (is_resource($value)) {
|
||||
return '(' . get_resource_type($value) . ' resource #' . (int) $value . ')';
|
||||
}
|
||||
|
||||
// If we don't know what it is, use var_export().
|
||||
if (!is_object($value)) {
|
||||
return '(' . var_export($value, true) . ')';
|
||||
}
|
||||
|
||||
// From here, $value should be an object.
|
||||
|
||||
// __toString() is implemented
|
||||
if (is_callable([$value, '__toString'])) {
|
||||
return (string) $value->__toString();
|
||||
}
|
||||
|
||||
// object of type \DateTime
|
||||
if ($value instanceof DateTimeInterface) {
|
||||
return $value->format('c');
|
||||
}
|
||||
|
||||
// unknown type
|
||||
// phpcs:ignore SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall
|
||||
return '(' . get_class($value) . ' Object)';
|
||||
}
|
||||
}
|
19
vendor/ramsey/uuid/LICENSE
vendored
Normal file
19
vendor/ramsey/uuid/LICENSE
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2012-2023 Ben Ramsey <ben@benramsey.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
83
vendor/ramsey/uuid/README.md
vendored
Normal file
83
vendor/ramsey/uuid/README.md
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
<h1 align="center">ramsey/uuid</h1>
|
||||
|
||||
<p align="center">
|
||||
<strong>A PHP library for generating and working with UUIDs.</strong>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/ramsey/uuid"><img src="http://img.shields.io/badge/source-ramsey/uuid-blue.svg?style=flat-square" alt="Source Code"></a>
|
||||
<a href="https://packagist.org/packages/ramsey/uuid"><img src="https://img.shields.io/packagist/v/ramsey/uuid.svg?style=flat-square&label=release" alt="Download Package"></a>
|
||||
<a href="https://php.net"><img src="https://img.shields.io/packagist/php-v/ramsey/uuid.svg?style=flat-square&colorB=%238892BF" alt="PHP Programming Language"></a>
|
||||
<a href="https://github.com/ramsey/uuid/blob/4.x/LICENSE"><img src="https://img.shields.io/packagist/l/ramsey/uuid.svg?style=flat-square&colorB=darkcyan" alt="Read License"></a>
|
||||
<a href="https://github.com/ramsey/uuid/actions/workflows/continuous-integration.yml"><img src="https://img.shields.io/github/actions/workflow/status/ramsey/uuid/continuous-integration.yml?branch=4.x&logo=github&style=flat-square" alt="Build Status"></a>
|
||||
<a href="https://app.codecov.io/gh/ramsey/uuid/branch/4.x"><img src="https://img.shields.io/codecov/c/github/ramsey/uuid/4.x?label=codecov&logo=codecov&style=flat-square" alt="Codecov Code Coverage"></a>
|
||||
<a href="https://shepherd.dev/github/ramsey/uuid"><img src="https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fshepherd.dev%2Fgithub%2Framsey%2Fuuid%2Fcoverage" alt="Psalm Type Coverage"></a>
|
||||
</p>
|
||||
|
||||
ramsey/uuid is a PHP library for generating and working with universally unique
|
||||
identifiers (UUIDs).
|
||||
|
||||
This project adheres to a [code of conduct](CODE_OF_CONDUCT.md).
|
||||
By participating in this project and its community, you are expected to
|
||||
uphold this code.
|
||||
|
||||
Much inspiration for this library came from the [Java][javauuid] and
|
||||
[Python][pyuuid] UUID libraries.
|
||||
|
||||
## Installation
|
||||
|
||||
The preferred method of installation is via [Composer][]. Run the following
|
||||
command to install the package and add it as a requirement to your project's
|
||||
`composer.json`:
|
||||
|
||||
```bash
|
||||
composer require ramsey/uuid
|
||||
```
|
||||
|
||||
## Upgrading to Version 4
|
||||
|
||||
See the documentation for a thorough upgrade guide:
|
||||
|
||||
* [Upgrading ramsey/uuid Version 3 to 4](https://uuid.ramsey.dev/en/stable/upgrading/3-to-4.html)
|
||||
|
||||
## Documentation
|
||||
|
||||
Please see <https://uuid.ramsey.dev> for documentation, tips, examples, and
|
||||
frequently asked questions.
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! To contribute, please familiarize yourself with
|
||||
[CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
|
||||
## Coordinated Disclosure
|
||||
|
||||
Keeping user information safe and secure is a top priority, and we welcome the
|
||||
contribution of external security researchers. If you believe you've found a
|
||||
security issue in software that is maintained in this repository, please read
|
||||
[SECURITY.md][] for instructions on submitting a vulnerability report.
|
||||
|
||||
## ramsey/uuid for Enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of ramsey/uuid and thousands of other packages are working with
|
||||
Tidelift to deliver commercial support and maintenance for the open source
|
||||
packages you use to build your applications. Save time, reduce risk, and improve
|
||||
code health, while paying the maintainers of the exact packages you use.
|
||||
[Learn more.](https://tidelift.com/subscription/pkg/packagist-ramsey-uuid?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
## Copyright and License
|
||||
|
||||
The ramsey/uuid library is copyright © [Ben Ramsey](https://benramsey.com/) and
|
||||
licensed for use under the MIT License (MIT). Please see [LICENSE][] for more
|
||||
information.
|
||||
|
||||
[rfc4122]: http://tools.ietf.org/html/rfc4122
|
||||
[conduct]: https://github.com/ramsey/uuid/blob/4.x/CODE_OF_CONDUCT.md
|
||||
[javauuid]: http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html
|
||||
[pyuuid]: http://docs.python.org/3/library/uuid.html
|
||||
[composer]: http://getcomposer.org/
|
||||
[contributing.md]: https://github.com/ramsey/uuid/blob/4.x/CONTRIBUTING.md
|
||||
[security.md]: https://github.com/ramsey/uuid/blob/4.x/SECURITY.md
|
||||
[license]: https://github.com/ramsey/uuid/blob/4.x/LICENSE
|
108
vendor/ramsey/uuid/composer.json
vendored
Normal file
108
vendor/ramsey/uuid/composer.json
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
{
|
||||
"name": "ramsey/uuid",
|
||||
"description": "A PHP library for generating and working with universally unique identifiers (UUIDs).",
|
||||
"license": "MIT",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"uuid",
|
||||
"identifier",
|
||||
"guid"
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.0",
|
||||
"ext-json": "*",
|
||||
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11",
|
||||
"ramsey/collection": "^1.2 || ^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"captainhook/captainhook": "^5.10",
|
||||
"captainhook/plugin-composer": "^5.3",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"doctrine/annotations": "^1.8",
|
||||
"ergebnis/composer-normalize": "^2.15",
|
||||
"mockery/mockery": "^1.3",
|
||||
"paragonie/random-lib": "^2",
|
||||
"php-mock/php-mock": "^2.2",
|
||||
"php-mock/php-mock-mockery": "^1.3",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.1",
|
||||
"phpbench/phpbench": "^1.0",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"phpstan/phpstan-mockery": "^1.1",
|
||||
"phpstan/phpstan-phpunit": "^1.1",
|
||||
"phpunit/phpunit": "^8.5 || ^9",
|
||||
"ramsey/composer-repl": "^1.4",
|
||||
"slevomat/coding-standard": "^8.4",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"vimeo/psalm": "^4.9"
|
||||
},
|
||||
"replace": {
|
||||
"rhumsaa/uuid": "self.version"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.",
|
||||
"ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.",
|
||||
"ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.",
|
||||
"paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
|
||||
"ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Ramsey\\Uuid\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Ramsey\\Uuid\\Benchmark\\": "tests/benchmark/",
|
||||
"Ramsey\\Uuid\\StaticAnalysis\\": "tests/static-analysis/",
|
||||
"Ramsey\\Uuid\\Test\\": "tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"captainhook/plugin-composer": true,
|
||||
"ergebnis/composer-normalize": true,
|
||||
"phpstan/extension-installer": true,
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"ramsey/composer-repl": true
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
"extra": {
|
||||
"captainhook": {
|
||||
"force-install": true
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"analyze": [
|
||||
"@phpstan",
|
||||
"@psalm"
|
||||
],
|
||||
"build:clean": "git clean -fX build/",
|
||||
"lint": "parallel-lint src tests",
|
||||
"lint:paths": "parallel-lint",
|
||||
"phpbench": "phpbench run",
|
||||
"phpcbf": "phpcbf -vpw --cache=build/cache/phpcs.cache",
|
||||
"phpcs": "phpcs --cache=build/cache/phpcs.cache",
|
||||
"phpstan": [
|
||||
"phpstan analyse --no-progress --memory-limit=1G",
|
||||
"phpstan analyse -c phpstan-tests.neon --no-progress --memory-limit=1G"
|
||||
],
|
||||
"phpunit": "phpunit --verbose --colors=always",
|
||||
"phpunit-coverage": "phpunit --verbose --colors=always --coverage-html build/coverage",
|
||||
"psalm": "psalm --show-info=false --config=psalm.xml",
|
||||
"test": [
|
||||
"@lint",
|
||||
"@phpbench",
|
||||
"@phpcs",
|
||||
"@phpstan",
|
||||
"@psalm",
|
||||
"@phpunit"
|
||||
]
|
||||
}
|
||||
}
|
63
vendor/ramsey/uuid/src/BinaryUtils.php
vendored
Normal file
63
vendor/ramsey/uuid/src/BinaryUtils.php
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid;
|
||||
|
||||
/**
|
||||
* Provides binary math utilities
|
||||
*/
|
||||
class BinaryUtils
|
||||
{
|
||||
/**
|
||||
* Applies the RFC 4122 variant field to the 16-bit clock sequence
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1.1 RFC 4122, § 4.1.1: Variant
|
||||
*
|
||||
* @param int $clockSeq The 16-bit clock sequence value before the RFC 4122
|
||||
* variant is applied
|
||||
*
|
||||
* @return int The 16-bit clock sequence multiplexed with the UUID variant
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function applyVariant(int $clockSeq): int
|
||||
{
|
||||
$clockSeq = $clockSeq & 0x3fff;
|
||||
$clockSeq |= 0x8000;
|
||||
|
||||
return $clockSeq;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the RFC 4122 version number to the 16-bit `time_hi_and_version` field
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1.3 RFC 4122, § 4.1.3: Version
|
||||
*
|
||||
* @param int $timeHi The value of the 16-bit `time_hi_and_version` field
|
||||
* before the RFC 4122 version is applied
|
||||
* @param int $version The RFC 4122 version to apply to the `time_hi` field
|
||||
*
|
||||
* @return int The 16-bit time_hi field of the timestamp multiplexed with
|
||||
* the UUID version number
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public static function applyVersion(int $timeHi, int $version): int
|
||||
{
|
||||
$timeHi = $timeHi & 0x0fff;
|
||||
$timeHi |= $version << 12;
|
||||
|
||||
return $timeHi;
|
||||
}
|
||||
}
|
85
vendor/ramsey/uuid/src/Builder/BuilderCollection.php
vendored
Normal file
85
vendor/ramsey/uuid/src/Builder/BuilderCollection.php
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Builder;
|
||||
|
||||
use Ramsey\Collection\AbstractCollection;
|
||||
use Ramsey\Uuid\Converter\Number\GenericNumberConverter;
|
||||
use Ramsey\Uuid\Converter\Time\GenericTimeConverter;
|
||||
use Ramsey\Uuid\Converter\Time\PhpTimeConverter;
|
||||
use Ramsey\Uuid\Guid\GuidBuilder;
|
||||
use Ramsey\Uuid\Math\BrickMathCalculator;
|
||||
use Ramsey\Uuid\Nonstandard\UuidBuilder as NonstandardUuidBuilder;
|
||||
use Ramsey\Uuid\Rfc4122\UuidBuilder as Rfc4122UuidBuilder;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* A collection of UuidBuilderInterface objects
|
||||
*
|
||||
* @deprecated this class has been deprecated, and will be removed in 5.0.0. The use-case for this class comes from
|
||||
* a pre-`phpstan/phpstan` and pre-`vimeo/psalm` ecosystem, in which type safety had to be mostly enforced
|
||||
* at runtime: that is no longer necessary, now that you can safely verify your code to be correct, and use
|
||||
* more generic types like `iterable<T>` instead.
|
||||
*
|
||||
* @extends AbstractCollection<UuidBuilderInterface>
|
||||
*/
|
||||
class BuilderCollection extends AbstractCollection
|
||||
{
|
||||
public function getType(): string
|
||||
{
|
||||
return UuidBuilderInterface::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-mutation-free
|
||||
* @psalm-suppress ImpureMethodCall
|
||||
* @psalm-suppress InvalidTemplateParam
|
||||
*/
|
||||
public function getIterator(): Traversable
|
||||
{
|
||||
return parent::getIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-constructs the object from its serialized form
|
||||
*
|
||||
* @param string $serialized The serialized PHP string to unserialize into
|
||||
* a UuidInterface instance
|
||||
*
|
||||
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
* @psalm-suppress RedundantConditionGivenDocblockType
|
||||
*/
|
||||
public function unserialize($serialized): void
|
||||
{
|
||||
/** @var array<array-key, UuidBuilderInterface> $data */
|
||||
$data = unserialize($serialized, [
|
||||
'allowed_classes' => [
|
||||
BrickMathCalculator::class,
|
||||
GenericNumberConverter::class,
|
||||
GenericTimeConverter::class,
|
||||
GuidBuilder::class,
|
||||
NonstandardUuidBuilder::class,
|
||||
PhpTimeConverter::class,
|
||||
Rfc4122UuidBuilder::class,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->data = array_filter(
|
||||
$data,
|
||||
function ($unserialized): bool {
|
||||
return $unserialized instanceof UuidBuilderInterface;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
26
vendor/ramsey/uuid/src/Builder/DefaultUuidBuilder.php
vendored
Normal file
26
vendor/ramsey/uuid/src/Builder/DefaultUuidBuilder.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Builder;
|
||||
|
||||
use Ramsey\Uuid\Rfc4122\UuidBuilder as Rfc4122UuidBuilder;
|
||||
|
||||
/**
|
||||
* @deprecated Transition to {@see Rfc4122UuidBuilder}.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class DefaultUuidBuilder extends Rfc4122UuidBuilder
|
||||
{
|
||||
}
|
67
vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php
vendored
Normal file
67
vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Builder;
|
||||
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\Time\DegradedTimeConverter;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
use Ramsey\Uuid\DegradedUuid;
|
||||
use Ramsey\Uuid\Rfc4122\Fields as Rfc4122Fields;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* @deprecated DegradedUuid instances are no longer necessary to support 32-bit
|
||||
* systems. Transition to {@see DefaultUuidBuilder}.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class DegradedUuidBuilder implements UuidBuilderInterface
|
||||
{
|
||||
private TimeConverterInterface $timeConverter;
|
||||
|
||||
/**
|
||||
* @param NumberConverterInterface $numberConverter The number converter to
|
||||
* use when constructing the DegradedUuid
|
||||
* @param TimeConverterInterface|null $timeConverter The time converter to use
|
||||
* for converting timestamps extracted from a UUID to Unix timestamps
|
||||
*/
|
||||
public function __construct(
|
||||
private NumberConverterInterface $numberConverter,
|
||||
?TimeConverterInterface $timeConverter = null
|
||||
) {
|
||||
$this->timeConverter = $timeConverter ?: new DegradedTimeConverter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and returns a DegradedUuid
|
||||
*
|
||||
* @param CodecInterface $codec The codec to use for building this DegradedUuid instance
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return DegradedUuid The DegradedUuidBuild returns an instance of Ramsey\Uuid\DegradedUuid
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||
{
|
||||
return new DegradedUuid(
|
||||
new Rfc4122Fields($bytes),
|
||||
$this->numberConverter,
|
||||
$codec,
|
||||
$this->timeConverter
|
||||
);
|
||||
}
|
||||
}
|
68
vendor/ramsey/uuid/src/Builder/FallbackBuilder.php
vendored
Normal file
68
vendor/ramsey/uuid/src/Builder/FallbackBuilder.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Builder;
|
||||
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Exception\BuilderNotFoundException;
|
||||
use Ramsey\Uuid\Exception\UnableToBuildUuidException;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* FallbackBuilder builds a UUID by stepping through a list of UUID builders
|
||||
* until a UUID can be constructed without exceptions
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class FallbackBuilder implements UuidBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @param iterable<UuidBuilderInterface> $builders An array of UUID builders
|
||||
*/
|
||||
public function __construct(private iterable $builders)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and returns a UuidInterface instance using the first builder that
|
||||
* succeeds
|
||||
*
|
||||
* @param CodecInterface $codec The codec to use for building this instance
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return UuidInterface an instance of a UUID object
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||
{
|
||||
$lastBuilderException = null;
|
||||
|
||||
foreach ($this->builders as $builder) {
|
||||
try {
|
||||
return $builder->build($codec, $bytes);
|
||||
} catch (UnableToBuildUuidException $exception) {
|
||||
$lastBuilderException = $exception;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
throw new BuilderNotFoundException(
|
||||
'Could not find a suitable builder for the provided codec and fields',
|
||||
0,
|
||||
$lastBuilderException
|
||||
);
|
||||
}
|
||||
}
|
39
vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php
vendored
Normal file
39
vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Builder;
|
||||
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* A UUID builder builds instances of UuidInterface
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
interface UuidBuilderInterface
|
||||
{
|
||||
/**
|
||||
* Builds and returns a UuidInterface
|
||||
*
|
||||
* @param CodecInterface $codec The codec to use for building this UuidInterface instance
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return UuidInterface Implementations may choose to return more specific
|
||||
* instances of UUIDs that implement UuidInterface
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface;
|
||||
}
|
71
vendor/ramsey/uuid/src/Codec/CodecInterface.php
vendored
Normal file
71
vendor/ramsey/uuid/src/Codec/CodecInterface.php
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Codec;
|
||||
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* A codec encodes and decodes a UUID according to defined rules
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
interface CodecInterface
|
||||
{
|
||||
/**
|
||||
* Returns a hexadecimal string representation of a UuidInterface
|
||||
*
|
||||
* @param UuidInterface $uuid The UUID for which to create a hexadecimal
|
||||
* string representation
|
||||
*
|
||||
* @return string Hexadecimal string representation of a UUID
|
||||
*
|
||||
* @psalm-return non-empty-string
|
||||
*/
|
||||
public function encode(UuidInterface $uuid): string;
|
||||
|
||||
/**
|
||||
* Returns a binary string representation of a UuidInterface
|
||||
*
|
||||
* @param UuidInterface $uuid The UUID for which to create a binary string
|
||||
* representation
|
||||
*
|
||||
* @return string Binary string representation of a UUID
|
||||
*
|
||||
* @psalm-return non-empty-string
|
||||
*/
|
||||
public function encodeBinary(UuidInterface $uuid): string;
|
||||
|
||||
/**
|
||||
* Returns a UuidInterface derived from a hexadecimal string representation
|
||||
*
|
||||
* @param string $encodedUuid The hexadecimal string representation to
|
||||
* convert into a UuidInterface instance
|
||||
*
|
||||
* @return UuidInterface An instance of a UUID decoded from a hexadecimal
|
||||
* string representation
|
||||
*/
|
||||
public function decode(string $encodedUuid): UuidInterface;
|
||||
|
||||
/**
|
||||
* Returns a UuidInterface derived from a binary string representation
|
||||
*
|
||||
* @param string $bytes The binary string representation to convert into a
|
||||
* UuidInterface instance
|
||||
*
|
||||
* @return UuidInterface An instance of a UUID decoded from a binary string
|
||||
* representation
|
||||
*/
|
||||
public function decodeBytes(string $bytes): UuidInterface;
|
||||
}
|
76
vendor/ramsey/uuid/src/Codec/GuidStringCodec.php
vendored
Normal file
76
vendor/ramsey/uuid/src/Codec/GuidStringCodec.php
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Codec;
|
||||
|
||||
use Ramsey\Uuid\Guid\Guid;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
use function bin2hex;
|
||||
use function sprintf;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* GuidStringCodec encodes and decodes globally unique identifiers (GUID)
|
||||
*
|
||||
* @see Guid
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class GuidStringCodec extends StringCodec
|
||||
{
|
||||
public function encode(UuidInterface $uuid): string
|
||||
{
|
||||
$hex = bin2hex($uuid->getFields()->getBytes());
|
||||
|
||||
/** @var non-empty-string */
|
||||
return sprintf(
|
||||
'%02s%02s%02s%02s-%02s%02s-%02s%02s-%04s-%012s',
|
||||
substr($hex, 6, 2),
|
||||
substr($hex, 4, 2),
|
||||
substr($hex, 2, 2),
|
||||
substr($hex, 0, 2),
|
||||
substr($hex, 10, 2),
|
||||
substr($hex, 8, 2),
|
||||
substr($hex, 14, 2),
|
||||
substr($hex, 12, 2),
|
||||
substr($hex, 16, 4),
|
||||
substr($hex, 20),
|
||||
);
|
||||
}
|
||||
|
||||
public function decode(string $encodedUuid): UuidInterface
|
||||
{
|
||||
$bytes = $this->getBytes($encodedUuid);
|
||||
|
||||
return $this->getBuilder()->build($this, $this->swapBytes($bytes));
|
||||
}
|
||||
|
||||
public function decodeBytes(string $bytes): UuidInterface
|
||||
{
|
||||
// Specifically call parent::decode to preserve correct byte order
|
||||
return parent::decode(bin2hex($bytes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps bytes according to the GUID rules
|
||||
*/
|
||||
private function swapBytes(string $bytes): string
|
||||
{
|
||||
return $bytes[3] . $bytes[2] . $bytes[1] . $bytes[0]
|
||||
. $bytes[5] . $bytes[4]
|
||||
. $bytes[7] . $bytes[6]
|
||||
. substr($bytes, 8);
|
||||
}
|
||||
}
|
113
vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php
vendored
Normal file
113
vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Codec;
|
||||
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Exception\UnsupportedOperationException;
|
||||
use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
use function strlen;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* OrderedTimeCodec encodes and decodes a UUID, optimizing the byte order for
|
||||
* more efficient storage
|
||||
*
|
||||
* For binary representations of version 1 UUID, this codec may be used to
|
||||
* reorganize the time fields, making the UUID closer to sequential when storing
|
||||
* the bytes. According to Percona, this optimization can improve database
|
||||
* INSERTs and SELECTs using the UUID column as a key.
|
||||
*
|
||||
* The string representation of the UUID will remain unchanged. Only the binary
|
||||
* representation is reordered.
|
||||
*
|
||||
* **PLEASE NOTE:** Binary representations of UUIDs encoded with this codec must
|
||||
* be decoded with this codec. Decoding using another codec can result in
|
||||
* malformed UUIDs.
|
||||
*
|
||||
* @link https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/ Storing UUID Values in MySQL
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class OrderedTimeCodec extends StringCodec
|
||||
{
|
||||
/**
|
||||
* Returns a binary string representation of a UUID, with the timestamp
|
||||
* fields rearranged for optimized storage
|
||||
*
|
||||
* @inheritDoc
|
||||
* @psalm-return non-empty-string
|
||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
||||
*/
|
||||
public function encodeBinary(UuidInterface $uuid): string
|
||||
{
|
||||
if (
|
||||
!($uuid->getFields() instanceof Rfc4122FieldsInterface)
|
||||
|| $uuid->getFields()->getVersion() !== Uuid::UUID_TYPE_TIME
|
||||
) {
|
||||
throw new InvalidArgumentException(
|
||||
'Expected RFC 4122 version 1 (time-based) UUID'
|
||||
);
|
||||
}
|
||||
|
||||
$bytes = $uuid->getFields()->getBytes();
|
||||
|
||||
/** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
|
||||
return $bytes[6] . $bytes[7]
|
||||
. $bytes[4] . $bytes[5]
|
||||
. $bytes[0] . $bytes[1] . $bytes[2] . $bytes[3]
|
||||
. substr($bytes, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a UuidInterface derived from an ordered-time binary string
|
||||
* representation
|
||||
*
|
||||
* @throws InvalidArgumentException if $bytes is an invalid length
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function decodeBytes(string $bytes): UuidInterface
|
||||
{
|
||||
if (strlen($bytes) !== 16) {
|
||||
throw new InvalidArgumentException(
|
||||
'$bytes string should contain 16 characters.'
|
||||
);
|
||||
}
|
||||
|
||||
// Rearrange the bytes to their original order.
|
||||
$rearrangedBytes = $bytes[4] . $bytes[5] . $bytes[6] . $bytes[7]
|
||||
. $bytes[2] . $bytes[3]
|
||||
. $bytes[0] . $bytes[1]
|
||||
. substr($bytes, 8);
|
||||
|
||||
$uuid = parent::decodeBytes($rearrangedBytes);
|
||||
|
||||
if (
|
||||
!($uuid->getFields() instanceof Rfc4122FieldsInterface)
|
||||
|| $uuid->getFields()->getVersion() !== Uuid::UUID_TYPE_TIME
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
'Attempting to decode a non-time-based UUID using '
|
||||
. 'OrderedTimeCodec'
|
||||
);
|
||||
}
|
||||
|
||||
return $uuid;
|
||||
}
|
||||
}
|
131
vendor/ramsey/uuid/src/Codec/StringCodec.php
vendored
Normal file
131
vendor/ramsey/uuid/src/Codec/StringCodec.php
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Codec;
|
||||
|
||||
use Ramsey\Uuid\Builder\UuidBuilderInterface;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Exception\InvalidUuidStringException;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
use function bin2hex;
|
||||
use function hex2bin;
|
||||
use function implode;
|
||||
use function sprintf;
|
||||
use function str_replace;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* StringCodec encodes and decodes RFC 4122 UUIDs
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc4122
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class StringCodec implements CodecInterface
|
||||
{
|
||||
/**
|
||||
* Constructs a StringCodec
|
||||
*
|
||||
* @param UuidBuilderInterface $builder The builder to use when encoding UUIDs
|
||||
*/
|
||||
public function __construct(private UuidBuilderInterface $builder)
|
||||
{
|
||||
}
|
||||
|
||||
public function encode(UuidInterface $uuid): string
|
||||
{
|
||||
$hex = bin2hex($uuid->getFields()->getBytes());
|
||||
|
||||
/** @var non-empty-string */
|
||||
return sprintf(
|
||||
'%08s-%04s-%04s-%04s-%012s',
|
||||
substr($hex, 0, 8),
|
||||
substr($hex, 8, 4),
|
||||
substr($hex, 12, 4),
|
||||
substr($hex, 16, 4),
|
||||
substr($hex, 20),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-return non-empty-string
|
||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
||||
*/
|
||||
public function encodeBinary(UuidInterface $uuid): string
|
||||
{
|
||||
/** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
|
||||
return $uuid->getFields()->getBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidUuidStringException
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function decode(string $encodedUuid): UuidInterface
|
||||
{
|
||||
return $this->builder->build($this, $this->getBytes($encodedUuid));
|
||||
}
|
||||
|
||||
public function decodeBytes(string $bytes): UuidInterface
|
||||
{
|
||||
if (strlen($bytes) !== 16) {
|
||||
throw new InvalidArgumentException(
|
||||
'$bytes string should contain 16 characters.'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->builder->build($this, $bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the UUID builder
|
||||
*/
|
||||
protected function getBuilder(): UuidBuilderInterface
|
||||
{
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a byte string of the UUID
|
||||
*/
|
||||
protected function getBytes(string $encodedUuid): string
|
||||
{
|
||||
$parsedUuid = str_replace(
|
||||
['urn:', 'uuid:', 'URN:', 'UUID:', '{', '}', '-'],
|
||||
'',
|
||||
$encodedUuid
|
||||
);
|
||||
|
||||
$components = [
|
||||
substr($parsedUuid, 0, 8),
|
||||
substr($parsedUuid, 8, 4),
|
||||
substr($parsedUuid, 12, 4),
|
||||
substr($parsedUuid, 16, 4),
|
||||
substr($parsedUuid, 20),
|
||||
];
|
||||
|
||||
if (!Uuid::isValid(implode('-', $components))) {
|
||||
throw new InvalidUuidStringException(
|
||||
'Invalid UUID string: ' . $encodedUuid
|
||||
);
|
||||
}
|
||||
|
||||
return (string) hex2bin($parsedUuid);
|
||||
}
|
||||
}
|
113
vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php
vendored
Normal file
113
vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Codec;
|
||||
|
||||
use Ramsey\Uuid\Exception\InvalidUuidStringException;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
use function bin2hex;
|
||||
use function sprintf;
|
||||
use function substr;
|
||||
use function substr_replace;
|
||||
|
||||
/**
|
||||
* TimestampFirstCombCodec encodes and decodes COMBs, with the timestamp as the
|
||||
* first 48 bits
|
||||
*
|
||||
* In contrast with the TimestampLastCombCodec, the TimestampFirstCombCodec
|
||||
* adds the timestamp to the first 48 bits of the COMB. To generate a
|
||||
* timestamp-first COMB, set the TimestampFirstCombCodec as the codec, along
|
||||
* with the CombGenerator as the random generator.
|
||||
*
|
||||
* ``` php
|
||||
* $factory = new UuidFactory();
|
||||
*
|
||||
* $factory->setCodec(new TimestampFirstCombCodec($factory->getUuidBuilder()));
|
||||
*
|
||||
* $factory->setRandomGenerator(new CombGenerator(
|
||||
* $factory->getRandomGenerator(),
|
||||
* $factory->getNumberConverter()
|
||||
* ));
|
||||
*
|
||||
* $timestampFirstComb = $factory->uuid4();
|
||||
* ```
|
||||
*
|
||||
* @link https://www.informit.com/articles/printerfriendly/25862 The Cost of GUIDs as Primary Keys
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class TimestampFirstCombCodec extends StringCodec
|
||||
{
|
||||
/**
|
||||
* @psalm-return non-empty-string
|
||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
||||
*/
|
||||
public function encode(UuidInterface $uuid): string
|
||||
{
|
||||
$bytes = $this->swapBytes($uuid->getFields()->getBytes());
|
||||
|
||||
return sprintf(
|
||||
'%08s-%04s-%04s-%04s-%012s',
|
||||
bin2hex(substr($bytes, 0, 4)),
|
||||
bin2hex(substr($bytes, 4, 2)),
|
||||
bin2hex(substr($bytes, 6, 2)),
|
||||
bin2hex(substr($bytes, 8, 2)),
|
||||
bin2hex(substr($bytes, 10))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-return non-empty-string
|
||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
||||
*/
|
||||
public function encodeBinary(UuidInterface $uuid): string
|
||||
{
|
||||
/** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
|
||||
return $this->swapBytes($uuid->getFields()->getBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidUuidStringException
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function decode(string $encodedUuid): UuidInterface
|
||||
{
|
||||
$bytes = $this->getBytes($encodedUuid);
|
||||
|
||||
return $this->getBuilder()->build($this, $this->swapBytes($bytes));
|
||||
}
|
||||
|
||||
public function decodeBytes(string $bytes): UuidInterface
|
||||
{
|
||||
return $this->getBuilder()->build($this, $this->swapBytes($bytes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps bytes according to the timestamp-first COMB rules
|
||||
*/
|
||||
private function swapBytes(string $bytes): string
|
||||
{
|
||||
$first48Bits = substr($bytes, 0, 6);
|
||||
$last48Bits = substr($bytes, -6);
|
||||
|
||||
$bytes = substr_replace($bytes, $last48Bits, 0, 6);
|
||||
$bytes = substr_replace($bytes, $first48Bits, -6);
|
||||
|
||||
return $bytes;
|
||||
}
|
||||
}
|
51
vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php
vendored
Normal file
51
vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Codec;
|
||||
|
||||
/**
|
||||
* TimestampLastCombCodec encodes and decodes COMBs, with the timestamp as the
|
||||
* last 48 bits
|
||||
*
|
||||
* The CombGenerator when used with the StringCodec (and, by proxy, the
|
||||
* TimestampLastCombCodec) adds the timestamp to the last 48 bits of the COMB.
|
||||
* The TimestampLastCombCodec is provided for the sake of consistency. In
|
||||
* practice, it is identical to the standard StringCodec but, it may be used
|
||||
* with the CombGenerator for additional context when reading code.
|
||||
*
|
||||
* Consider the following code. By default, the codec used by UuidFactory is the
|
||||
* StringCodec, but here, we explicitly set the TimestampLastCombCodec. It is
|
||||
* redundant, but it is clear that we intend this COMB to be generated with the
|
||||
* timestamp appearing at the end.
|
||||
*
|
||||
* ``` php
|
||||
* $factory = new UuidFactory();
|
||||
*
|
||||
* $factory->setCodec(new TimestampLastCombCodec($factory->getUuidBuilder()));
|
||||
*
|
||||
* $factory->setRandomGenerator(new CombGenerator(
|
||||
* $factory->getRandomGenerator(),
|
||||
* $factory->getNumberConverter()
|
||||
* ));
|
||||
*
|
||||
* $timestampLastComb = $factory->uuid4();
|
||||
* ```
|
||||
*
|
||||
* @link https://www.informit.com/articles/printerfriendly/25862 The Cost of GUIDs as Primary Keys
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class TimestampLastCombCodec extends StringCodec
|
||||
{
|
||||
}
|
54
vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
vendored
Normal file
54
vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Converter\Number;
|
||||
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Math\BrickMathCalculator;
|
||||
|
||||
/**
|
||||
* Previously used to integrate moontoast/math as a bignum arithmetic library,
|
||||
* BigNumberConverter is deprecated in favor of GenericNumberConverter
|
||||
*
|
||||
* @deprecated Transition to {@see GenericNumberConverter}.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class BigNumberConverter implements NumberConverterInterface
|
||||
{
|
||||
private NumberConverterInterface $converter;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->converter = new GenericNumberConverter(new BrickMathCalculator());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function fromHex(string $hex): string
|
||||
{
|
||||
return $this->converter->fromHex($hex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function toHex(string $number): string
|
||||
{
|
||||
return $this->converter->toHex($number);
|
||||
}
|
||||
}
|
25
vendor/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php
vendored
Normal file
25
vendor/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Converter\Number;
|
||||
|
||||
/**
|
||||
* @deprecated DegradedNumberConverter is no longer necessary for converting
|
||||
* numbers on 32-bit systems. Transition to {@see GenericNumberConverter}.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class DegradedNumberConverter extends BigNumberConverter
|
||||
{
|
||||
}
|
57
vendor/ramsey/uuid/src/Converter/Number/GenericNumberConverter.php
vendored
Normal file
57
vendor/ramsey/uuid/src/Converter/Number/GenericNumberConverter.php
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Converter\Number;
|
||||
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Math\CalculatorInterface;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
/**
|
||||
* GenericNumberConverter uses the provided calculator to convert decimal
|
||||
* numbers to and from hexadecimal values
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class GenericNumberConverter implements NumberConverterInterface
|
||||
{
|
||||
public function __construct(private CalculatorInterface $calculator)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @psalm-pure
|
||||
* @psalm-return numeric-string
|
||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
||||
*/
|
||||
public function fromHex(string $hex): string
|
||||
{
|
||||
return $this->calculator->fromBase($hex, 16)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @psalm-pure
|
||||
* @psalm-return non-empty-string
|
||||
* @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty
|
||||
* @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty
|
||||
*/
|
||||
public function toHex(string $number): string
|
||||
{
|
||||
/** @phpstan-ignore-next-line PHPStan complains that this is not a non-empty-string. */
|
||||
return $this->calculator->toBase(new IntegerObject($number), 16);
|
||||
}
|
||||
}
|
57
vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php
vendored
Normal file
57
vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Converter;
|
||||
|
||||
/**
|
||||
* A number converter converts UUIDs from hexadecimal characters into
|
||||
* representations of integers and vice versa
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
interface NumberConverterInterface
|
||||
{
|
||||
/**
|
||||
* Converts a hexadecimal number into an string integer representation of
|
||||
* the number
|
||||
*
|
||||
* The integer representation returned is a string representation of the
|
||||
* integer, to accommodate unsigned integers greater than PHP_INT_MAX.
|
||||
*
|
||||
* @param string $hex The hexadecimal string representation to convert
|
||||
*
|
||||
* @return string String representation of an integer
|
||||
*
|
||||
* @psalm-return numeric-string
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function fromHex(string $hex): string;
|
||||
|
||||
/**
|
||||
* Converts a string integer representation into a hexadecimal string
|
||||
* representation of the number
|
||||
*
|
||||
* @param string $number A string integer representation to convert; this
|
||||
* must be a numeric string to accommodate unsigned integers greater
|
||||
* than PHP_INT_MAX.
|
||||
*
|
||||
* @return string Hexadecimal string
|
||||
*
|
||||
* @psalm-return non-empty-string
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function toHex(string $number): string;
|
||||
}
|
48
vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php
vendored
Normal file
48
vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Converter\Time;
|
||||
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
use Ramsey\Uuid\Math\BrickMathCalculator;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\Time;
|
||||
|
||||
/**
|
||||
* Previously used to integrate moontoast/math as a bignum arithmetic library,
|
||||
* BigNumberTimeConverter is deprecated in favor of GenericTimeConverter
|
||||
*
|
||||
* @deprecated Transition to {@see GenericTimeConverter}.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class BigNumberTimeConverter implements TimeConverterInterface
|
||||
{
|
||||
private TimeConverterInterface $converter;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->converter = new GenericTimeConverter(new BrickMathCalculator());
|
||||
}
|
||||
|
||||
public function calculateTime(string $seconds, string $microseconds): Hexadecimal
|
||||
{
|
||||
return $this->converter->calculateTime($seconds, $microseconds);
|
||||
}
|
||||
|
||||
public function convertTime(Hexadecimal $uuidTimestamp): Time
|
||||
{
|
||||
return $this->converter->convertTime($uuidTimestamp);
|
||||
}
|
||||
}
|
25
vendor/ramsey/uuid/src/Converter/Time/DegradedTimeConverter.php
vendored
Normal file
25
vendor/ramsey/uuid/src/Converter/Time/DegradedTimeConverter.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Converter\Time;
|
||||
|
||||
/**
|
||||
* @deprecated DegradedTimeConverter is no longer necessary for converting
|
||||
* time on 32-bit systems. Transition to {@see GenericTimeConverter}.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class DegradedTimeConverter extends BigNumberTimeConverter
|
||||
{
|
||||
}
|
118
vendor/ramsey/uuid/src/Converter/Time/GenericTimeConverter.php
vendored
Normal file
118
vendor/ramsey/uuid/src/Converter/Time/GenericTimeConverter.php
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Converter\Time;
|
||||
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
use Ramsey\Uuid\Math\CalculatorInterface;
|
||||
use Ramsey\Uuid\Math\RoundingMode;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Type\Time;
|
||||
|
||||
use function explode;
|
||||
use function str_pad;
|
||||
|
||||
use const STR_PAD_LEFT;
|
||||
|
||||
/**
|
||||
* GenericTimeConverter uses the provided calculator to calculate and convert
|
||||
* time values
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class GenericTimeConverter implements TimeConverterInterface
|
||||
{
|
||||
/**
|
||||
* The number of 100-nanosecond intervals from the Gregorian calendar epoch
|
||||
* to the Unix epoch.
|
||||
*/
|
||||
private const GREGORIAN_TO_UNIX_INTERVALS = '122192928000000000';
|
||||
|
||||
/**
|
||||
* The number of 100-nanosecond intervals in one second.
|
||||
*/
|
||||
private const SECOND_INTERVALS = '10000000';
|
||||
|
||||
/**
|
||||
* The number of 100-nanosecond intervals in one microsecond.
|
||||
*/
|
||||
private const MICROSECOND_INTERVALS = '10';
|
||||
|
||||
public function __construct(private CalculatorInterface $calculator)
|
||||
{
|
||||
}
|
||||
|
||||
public function calculateTime(string $seconds, string $microseconds): Hexadecimal
|
||||
{
|
||||
$timestamp = new Time($seconds, $microseconds);
|
||||
|
||||
// Convert the seconds into a count of 100-nanosecond intervals.
|
||||
$sec = $this->calculator->multiply(
|
||||
$timestamp->getSeconds(),
|
||||
new IntegerObject(self::SECOND_INTERVALS)
|
||||
);
|
||||
|
||||
// Convert the microseconds into a count of 100-nanosecond intervals.
|
||||
$usec = $this->calculator->multiply(
|
||||
$timestamp->getMicroseconds(),
|
||||
new IntegerObject(self::MICROSECOND_INTERVALS)
|
||||
);
|
||||
|
||||
// Combine the seconds and microseconds intervals and add the count of
|
||||
// 100-nanosecond intervals from the Gregorian calendar epoch to the
|
||||
// Unix epoch. This gives us the correct count of 100-nanosecond
|
||||
// intervals since the Gregorian calendar epoch for the given seconds
|
||||
// and microseconds.
|
||||
/** @var IntegerObject $uuidTime */
|
||||
$uuidTime = $this->calculator->add(
|
||||
$sec,
|
||||
$usec,
|
||||
new IntegerObject(self::GREGORIAN_TO_UNIX_INTERVALS)
|
||||
);
|
||||
|
||||
$uuidTimeHex = str_pad(
|
||||
$this->calculator->toHexadecimal($uuidTime)->toString(),
|
||||
16,
|
||||
'0',
|
||||
STR_PAD_LEFT
|
||||
);
|
||||
|
||||
return new Hexadecimal($uuidTimeHex);
|
||||
}
|
||||
|
||||
public function convertTime(Hexadecimal $uuidTimestamp): Time
|
||||
{
|
||||
// From the total, subtract the number of 100-nanosecond intervals from
|
||||
// the Gregorian calendar epoch to the Unix epoch. This gives us the
|
||||
// number of 100-nanosecond intervals from the Unix epoch, which also
|
||||
// includes the microtime.
|
||||
$epochNanoseconds = $this->calculator->subtract(
|
||||
$this->calculator->toInteger($uuidTimestamp),
|
||||
new IntegerObject(self::GREGORIAN_TO_UNIX_INTERVALS)
|
||||
);
|
||||
|
||||
// Convert the 100-nanosecond intervals into seconds and microseconds.
|
||||
$unixTimestamp = $this->calculator->divide(
|
||||
RoundingMode::HALF_UP,
|
||||
6,
|
||||
$epochNanoseconds,
|
||||
new IntegerObject(self::SECOND_INTERVALS)
|
||||
);
|
||||
|
||||
$split = explode('.', (string) $unixTimestamp, 2);
|
||||
|
||||
return new Time($split[0], $split[1] ?? 0);
|
||||
}
|
||||
}
|
172
vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php
vendored
Normal file
172
vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Converter\Time;
|
||||
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
use Ramsey\Uuid\Math\BrickMathCalculator;
|
||||
use Ramsey\Uuid\Math\CalculatorInterface;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Type\Time;
|
||||
|
||||
use function count;
|
||||
use function dechex;
|
||||
use function explode;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function str_pad;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
|
||||
use const STR_PAD_LEFT;
|
||||
use const STR_PAD_RIGHT;
|
||||
|
||||
/**
|
||||
* PhpTimeConverter uses built-in PHP functions and standard math operations
|
||||
* available to the PHP programming language to provide facilities for
|
||||
* converting parts of time into representations that may be used in UUIDs
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class PhpTimeConverter implements TimeConverterInterface
|
||||
{
|
||||
/**
|
||||
* The number of 100-nanosecond intervals from the Gregorian calendar epoch
|
||||
* to the Unix epoch.
|
||||
*/
|
||||
private const GREGORIAN_TO_UNIX_INTERVALS = 0x01b21dd213814000;
|
||||
|
||||
/**
|
||||
* The number of 100-nanosecond intervals in one second.
|
||||
*/
|
||||
private const SECOND_INTERVALS = 10000000;
|
||||
|
||||
/**
|
||||
* The number of 100-nanosecond intervals in one microsecond.
|
||||
*/
|
||||
private const MICROSECOND_INTERVALS = 10;
|
||||
|
||||
private int $phpPrecision;
|
||||
private CalculatorInterface $calculator;
|
||||
private TimeConverterInterface $fallbackConverter;
|
||||
|
||||
public function __construct(
|
||||
?CalculatorInterface $calculator = null,
|
||||
?TimeConverterInterface $fallbackConverter = null
|
||||
) {
|
||||
if ($calculator === null) {
|
||||
$calculator = new BrickMathCalculator();
|
||||
}
|
||||
|
||||
if ($fallbackConverter === null) {
|
||||
$fallbackConverter = new GenericTimeConverter($calculator);
|
||||
}
|
||||
|
||||
$this->calculator = $calculator;
|
||||
$this->fallbackConverter = $fallbackConverter;
|
||||
$this->phpPrecision = (int) ini_get('precision');
|
||||
}
|
||||
|
||||
public function calculateTime(string $seconds, string $microseconds): Hexadecimal
|
||||
{
|
||||
$seconds = new IntegerObject($seconds);
|
||||
$microseconds = new IntegerObject($microseconds);
|
||||
|
||||
// Calculate the count of 100-nanosecond intervals since the Gregorian
|
||||
// calendar epoch for the given seconds and microseconds.
|
||||
$uuidTime = ((int) $seconds->toString() * self::SECOND_INTERVALS)
|
||||
+ ((int) $microseconds->toString() * self::MICROSECOND_INTERVALS)
|
||||
+ self::GREGORIAN_TO_UNIX_INTERVALS;
|
||||
|
||||
// Check to see whether we've overflowed the max/min integer size.
|
||||
// If so, we will default to a different time converter.
|
||||
/** @psalm-suppress RedundantCondition */
|
||||
if (!is_int($uuidTime)) {
|
||||
return $this->fallbackConverter->calculateTime(
|
||||
$seconds->toString(),
|
||||
$microseconds->toString()
|
||||
);
|
||||
}
|
||||
|
||||
return new Hexadecimal(str_pad(dechex($uuidTime), 16, '0', STR_PAD_LEFT));
|
||||
}
|
||||
|
||||
public function convertTime(Hexadecimal $uuidTimestamp): Time
|
||||
{
|
||||
$timestamp = $this->calculator->toInteger($uuidTimestamp);
|
||||
|
||||
// Convert the 100-nanosecond intervals into seconds and microseconds.
|
||||
$splitTime = $this->splitTime(
|
||||
((int) $timestamp->toString() - self::GREGORIAN_TO_UNIX_INTERVALS)
|
||||
/ self::SECOND_INTERVALS
|
||||
);
|
||||
|
||||
if (count($splitTime) === 0) {
|
||||
return $this->fallbackConverter->convertTime($uuidTimestamp);
|
||||
}
|
||||
|
||||
return new Time($splitTime['sec'], $splitTime['usec']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float|int $time The time to split into seconds and microseconds
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function splitTime(float | int $time): array
|
||||
{
|
||||
$split = explode('.', (string) $time, 2);
|
||||
|
||||
// If the $time value is a float but $split only has 1 element, then the
|
||||
// float math was rounded up to the next second, so we want to return
|
||||
// an empty array to allow use of the fallback converter.
|
||||
if (is_float($time) && count($split) === 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (count($split) === 1) {
|
||||
return [
|
||||
'sec' => $split[0],
|
||||
'usec' => '0',
|
||||
];
|
||||
}
|
||||
|
||||
// If the microseconds are less than six characters AND the length of
|
||||
// the number is greater than or equal to the PHP precision, then it's
|
||||
// possible that we lost some precision for the microseconds. Return an
|
||||
// empty array, so that we can choose to use the fallback converter.
|
||||
if (strlen($split[1]) < 6 && strlen((string) $time) >= $this->phpPrecision) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$microseconds = $split[1];
|
||||
|
||||
// Ensure the microseconds are no longer than 6 digits. If they are,
|
||||
// truncate the number to the first 6 digits and round up, if needed.
|
||||
if (strlen($microseconds) > 6) {
|
||||
$roundingDigit = (int) substr($microseconds, 6, 1);
|
||||
$microseconds = (int) substr($microseconds, 0, 6);
|
||||
|
||||
if ($roundingDigit >= 5) {
|
||||
$microseconds++;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'sec' => $split[0],
|
||||
'usec' => str_pad((string) $microseconds, 6, '0', STR_PAD_RIGHT),
|
||||
];
|
||||
}
|
||||
}
|
90
vendor/ramsey/uuid/src/Converter/Time/UnixTimeConverter.php
vendored
Normal file
90
vendor/ramsey/uuid/src/Converter/Time/UnixTimeConverter.php
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Converter\Time;
|
||||
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
use Ramsey\Uuid\Math\CalculatorInterface;
|
||||
use Ramsey\Uuid\Math\RoundingMode;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Type\Time;
|
||||
|
||||
use function explode;
|
||||
use function str_pad;
|
||||
|
||||
use const STR_PAD_LEFT;
|
||||
|
||||
/**
|
||||
* UnixTimeConverter converts Unix Epoch timestamps to/from hexadecimal values
|
||||
* consisting of milliseconds elapsed since the Unix Epoch
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class UnixTimeConverter implements TimeConverterInterface
|
||||
{
|
||||
private const MILLISECONDS = 1000;
|
||||
|
||||
public function __construct(private CalculatorInterface $calculator)
|
||||
{
|
||||
}
|
||||
|
||||
public function calculateTime(string $seconds, string $microseconds): Hexadecimal
|
||||
{
|
||||
$timestamp = new Time($seconds, $microseconds);
|
||||
|
||||
// Convert the seconds into milliseconds.
|
||||
$sec = $this->calculator->multiply(
|
||||
$timestamp->getSeconds(),
|
||||
new IntegerObject(self::MILLISECONDS),
|
||||
);
|
||||
|
||||
// Convert the microseconds into milliseconds; the scale is zero because
|
||||
// we need to discard the fractional part.
|
||||
$usec = $this->calculator->divide(
|
||||
RoundingMode::DOWN, // Always round down to stay in the previous millisecond.
|
||||
0,
|
||||
$timestamp->getMicroseconds(),
|
||||
new IntegerObject(self::MILLISECONDS),
|
||||
);
|
||||
|
||||
/** @var IntegerObject $unixTime */
|
||||
$unixTime = $this->calculator->add($sec, $usec);
|
||||
|
||||
$unixTimeHex = str_pad(
|
||||
$this->calculator->toHexadecimal($unixTime)->toString(),
|
||||
12,
|
||||
'0',
|
||||
STR_PAD_LEFT
|
||||
);
|
||||
|
||||
return new Hexadecimal($unixTimeHex);
|
||||
}
|
||||
|
||||
public function convertTime(Hexadecimal $uuidTimestamp): Time
|
||||
{
|
||||
$milliseconds = $this->calculator->toInteger($uuidTimestamp);
|
||||
|
||||
$unixTimestamp = $this->calculator->divide(
|
||||
RoundingMode::HALF_UP,
|
||||
6,
|
||||
$milliseconds,
|
||||
new IntegerObject(self::MILLISECONDS)
|
||||
);
|
||||
|
||||
$split = explode('.', (string) $unixTimestamp, 2);
|
||||
|
||||
return new Time($split[0], $split[1] ?? '0');
|
||||
}
|
||||
}
|
58
vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php
vendored
Normal file
58
vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Converter;
|
||||
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\Time;
|
||||
|
||||
/**
|
||||
* A time converter converts timestamps into representations that may be used
|
||||
* in UUIDs
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
interface TimeConverterInterface
|
||||
{
|
||||
/**
|
||||
* Uses the provided seconds and micro-seconds to calculate the count of
|
||||
* 100-nanosecond intervals since UTC 00:00:00.00, 15 October 1582, for
|
||||
* RFC 4122 variant UUIDs
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.2.2 RFC 4122, § 4.2.2: Generation Details
|
||||
*
|
||||
* @param string $seconds A string representation of the number of seconds
|
||||
* since the Unix epoch for the time to calculate
|
||||
* @param string $microseconds A string representation of the micro-seconds
|
||||
* associated with the time to calculate
|
||||
*
|
||||
* @return Hexadecimal The full UUID timestamp as a Hexadecimal value
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function calculateTime(string $seconds, string $microseconds): Hexadecimal;
|
||||
|
||||
/**
|
||||
* Converts a timestamp extracted from a UUID to a Unix timestamp
|
||||
*
|
||||
* @param Hexadecimal $uuidTimestamp A hexadecimal representation of a UUID
|
||||
* timestamp; a UUID timestamp is a count of 100-nanosecond intervals
|
||||
* since UTC 00:00:00.00, 15 October 1582.
|
||||
*
|
||||
* @return Time An instance of {@see Time}
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function convertTime(Hexadecimal $uuidTimestamp): Time;
|
||||
}
|
25
vendor/ramsey/uuid/src/DegradedUuid.php
vendored
Normal file
25
vendor/ramsey/uuid/src/DegradedUuid.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid;
|
||||
|
||||
/**
|
||||
* @deprecated DegradedUuid is no longer necessary to represent UUIDs on 32-bit
|
||||
* systems. Transition typehints to {@see UuidInterface}.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class DegradedUuid extends Uuid
|
||||
{
|
||||
}
|
140
vendor/ramsey/uuid/src/DeprecatedUuidInterface.php
vendored
Normal file
140
vendor/ramsey/uuid/src/DeprecatedUuidInterface.php
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
|
||||
/**
|
||||
* This interface encapsulates deprecated methods for ramsey/uuid
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
interface DeprecatedUuidInterface
|
||||
{
|
||||
/**
|
||||
* @deprecated This method will be removed in 5.0.0. There is no alternative
|
||||
* recommendation, so plan accordingly.
|
||||
*/
|
||||
public function getNumberConverter(): NumberConverterInterface;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFieldsHex(): array;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqHiAndReserved()}.
|
||||
*/
|
||||
public function getClockSeqHiAndReservedHex(): string;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqLow()}.
|
||||
*/
|
||||
public function getClockSeqLowHex(): string;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeq()}.
|
||||
*/
|
||||
public function getClockSequenceHex(): string;
|
||||
|
||||
/**
|
||||
* @deprecated In ramsey/uuid version 5.0.0, this will be removed from the
|
||||
* interface. It is available at {@see UuidV1::getDateTime()}.
|
||||
*/
|
||||
public function getDateTime(): DateTimeInterface;
|
||||
|
||||
/**
|
||||
* @deprecated This method will be removed in 5.0.0. There is no direct
|
||||
* alternative, but the same information may be obtained by splitting
|
||||
* in half the value returned by {@see UuidInterface::getHex()}.
|
||||
*/
|
||||
public function getLeastSignificantBitsHex(): string;
|
||||
|
||||
/**
|
||||
* @deprecated This method will be removed in 5.0.0. There is no direct
|
||||
* alternative, but the same information may be obtained by splitting
|
||||
* in half the value returned by {@see UuidInterface::getHex()}.
|
||||
*/
|
||||
public function getMostSignificantBitsHex(): string;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getNode()}.
|
||||
*/
|
||||
public function getNodeHex(): string;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeHiAndVersion()}.
|
||||
*/
|
||||
public function getTimeHiAndVersionHex(): string;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeLow()}.
|
||||
*/
|
||||
public function getTimeLowHex(): string;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeMid()}.
|
||||
*/
|
||||
public function getTimeMidHex(): string;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimestamp()}.
|
||||
*/
|
||||
public function getTimestampHex(): string;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getVariant()}.
|
||||
*/
|
||||
public function getVariant(): ?int;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getVersion()}.
|
||||
*/
|
||||
public function getVersion(): ?int;
|
||||
}
|
360
vendor/ramsey/uuid/src/DeprecatedUuidMethodsTrait.php
vendored
Normal file
360
vendor/ramsey/uuid/src/DeprecatedUuidMethodsTrait.php
vendored
Normal file
@ -0,0 +1,360 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Exception\DateTimeException;
|
||||
use Ramsey\Uuid\Exception\UnsupportedOperationException;
|
||||
use Throwable;
|
||||
|
||||
use function str_pad;
|
||||
use function substr;
|
||||
|
||||
use const STR_PAD_LEFT;
|
||||
|
||||
/**
|
||||
* This trait encapsulates deprecated methods for ramsey/uuid; this trait and
|
||||
* its methods will be removed in ramsey/uuid 5.0.0.
|
||||
*
|
||||
* @deprecated This trait and its methods will be removed in ramsey/uuid 5.0.0.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
trait DeprecatedUuidMethodsTrait
|
||||
{
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqHiAndReserved()}
|
||||
* and use the arbitrary-precision math library of your choice to
|
||||
* convert it to a string integer.
|
||||
*/
|
||||
public function getClockSeqHiAndReserved(): string
|
||||
{
|
||||
return $this->numberConverter->fromHex($this->fields->getClockSeqHiAndReserved()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqHiAndReserved()}.
|
||||
*/
|
||||
public function getClockSeqHiAndReservedHex(): string
|
||||
{
|
||||
return $this->fields->getClockSeqHiAndReserved()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqLow()}
|
||||
* and use the arbitrary-precision math library of your choice to
|
||||
* convert it to a string integer.
|
||||
*/
|
||||
public function getClockSeqLow(): string
|
||||
{
|
||||
return $this->numberConverter->fromHex($this->fields->getClockSeqLow()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqLow()}.
|
||||
*/
|
||||
public function getClockSeqLowHex(): string
|
||||
{
|
||||
return $this->fields->getClockSeqLow()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeq()}
|
||||
* and use the arbitrary-precision math library of your choice to
|
||||
* convert it to a string integer.
|
||||
*/
|
||||
public function getClockSequence(): string
|
||||
{
|
||||
return $this->numberConverter->fromHex($this->fields->getClockSeq()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeq()}.
|
||||
*/
|
||||
public function getClockSequenceHex(): string
|
||||
{
|
||||
return $this->fields->getClockSeq()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method will be removed in 5.0.0. There is no alternative
|
||||
* recommendation, so plan accordingly.
|
||||
*/
|
||||
public function getNumberConverter(): NumberConverterInterface
|
||||
{
|
||||
return $this->numberConverter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated In ramsey/uuid version 5.0.0, this will be removed.
|
||||
* It is available at {@see UuidV1::getDateTime()}.
|
||||
*
|
||||
* @return DateTimeImmutable An immutable instance of DateTimeInterface
|
||||
*
|
||||
* @throws UnsupportedOperationException if UUID is not time-based
|
||||
* @throws DateTimeException if DateTime throws an exception/error
|
||||
*/
|
||||
public function getDateTime(): DateTimeInterface
|
||||
{
|
||||
if ($this->fields->getVersion() !== 1) {
|
||||
throw new UnsupportedOperationException('Not a time-based UUID');
|
||||
}
|
||||
|
||||
$time = $this->timeConverter->convertTime($this->fields->getTimestamp());
|
||||
|
||||
try {
|
||||
return new DateTimeImmutable(
|
||||
'@'
|
||||
. $time->getSeconds()->toString()
|
||||
. '.'
|
||||
. str_pad($time->getMicroseconds()->toString(), 6, '0', STR_PAD_LEFT)
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
throw new DateTimeException($e->getMessage(), (int) $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFieldsHex(): array
|
||||
{
|
||||
return [
|
||||
'time_low' => $this->fields->getTimeLow()->toString(),
|
||||
'time_mid' => $this->fields->getTimeMid()->toString(),
|
||||
'time_hi_and_version' => $this->fields->getTimeHiAndVersion()->toString(),
|
||||
'clock_seq_hi_and_reserved' => $this->fields->getClockSeqHiAndReserved()->toString(),
|
||||
'clock_seq_low' => $this->fields->getClockSeqLow()->toString(),
|
||||
'node' => $this->fields->getNode()->toString(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method will be removed in 5.0.0. There is no direct
|
||||
* alternative, but the same information may be obtained by splitting
|
||||
* in half the value returned by {@see UuidInterface::getHex()}.
|
||||
*/
|
||||
public function getLeastSignificantBits(): string
|
||||
{
|
||||
$leastSignificantHex = substr($this->getHex()->toString(), 16);
|
||||
|
||||
return $this->numberConverter->fromHex($leastSignificantHex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method will be removed in 5.0.0. There is no direct
|
||||
* alternative, but the same information may be obtained by splitting
|
||||
* in half the value returned by {@see UuidInterface::getHex()}.
|
||||
*/
|
||||
public function getLeastSignificantBitsHex(): string
|
||||
{
|
||||
return substr($this->getHex()->toString(), 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method will be removed in 5.0.0. There is no direct
|
||||
* alternative, but the same information may be obtained by splitting
|
||||
* in half the value returned by {@see UuidInterface::getHex()}.
|
||||
*/
|
||||
public function getMostSignificantBits(): string
|
||||
{
|
||||
$mostSignificantHex = substr($this->getHex()->toString(), 0, 16);
|
||||
|
||||
return $this->numberConverter->fromHex($mostSignificantHex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method will be removed in 5.0.0. There is no direct
|
||||
* alternative, but the same information may be obtained by splitting
|
||||
* in half the value returned by {@see UuidInterface::getHex()}.
|
||||
*/
|
||||
public function getMostSignificantBitsHex(): string
|
||||
{
|
||||
return substr($this->getHex()->toString(), 0, 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getNode()} and use the
|
||||
* arbitrary-precision math library of your choice to convert it to a
|
||||
* string integer.
|
||||
*/
|
||||
public function getNode(): string
|
||||
{
|
||||
return $this->numberConverter->fromHex($this->fields->getNode()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getNode()}.
|
||||
*/
|
||||
public function getNodeHex(): string
|
||||
{
|
||||
return $this->fields->getNode()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeHiAndVersion()}
|
||||
* and use the arbitrary-precision math library of your choice to
|
||||
* convert it to a string integer.
|
||||
*/
|
||||
public function getTimeHiAndVersion(): string
|
||||
{
|
||||
return $this->numberConverter->fromHex($this->fields->getTimeHiAndVersion()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeHiAndVersion()}.
|
||||
*/
|
||||
public function getTimeHiAndVersionHex(): string
|
||||
{
|
||||
return $this->fields->getTimeHiAndVersion()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeLow()} and use the
|
||||
* arbitrary-precision math library of your choice to convert it to a
|
||||
* string integer.
|
||||
*/
|
||||
public function getTimeLow(): string
|
||||
{
|
||||
return $this->numberConverter->fromHex($this->fields->getTimeLow()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeLow()}.
|
||||
*/
|
||||
public function getTimeLowHex(): string
|
||||
{
|
||||
return $this->fields->getTimeLow()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeMid()} and use the
|
||||
* arbitrary-precision math library of your choice to convert it to a
|
||||
* string integer.
|
||||
*/
|
||||
public function getTimeMid(): string
|
||||
{
|
||||
return $this->numberConverter->fromHex($this->fields->getTimeMid()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeMid()}.
|
||||
*/
|
||||
public function getTimeMidHex(): string
|
||||
{
|
||||
return $this->fields->getTimeMid()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimestamp()} and use
|
||||
* the arbitrary-precision math library of your choice to convert it to
|
||||
* a string integer.
|
||||
*/
|
||||
public function getTimestamp(): string
|
||||
{
|
||||
if ($this->fields->getVersion() !== 1) {
|
||||
throw new UnsupportedOperationException('Not a time-based UUID');
|
||||
}
|
||||
|
||||
return $this->numberConverter->fromHex($this->fields->getTimestamp()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimestamp()}.
|
||||
*/
|
||||
public function getTimestampHex(): string
|
||||
{
|
||||
if ($this->fields->getVersion() !== 1) {
|
||||
throw new UnsupportedOperationException('Not a time-based UUID');
|
||||
}
|
||||
|
||||
return $this->fields->getTimestamp()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getVariant()}.
|
||||
*/
|
||||
public function getVariant(): ?int
|
||||
{
|
||||
return $this->fields->getVariant();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see UuidInterface::getFields()} to get a
|
||||
* {@see \Ramsey\Uuid\Fields\FieldsInterface} instance. If it is a
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
|
||||
* {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getVersion()}.
|
||||
*/
|
||||
public function getVersion(): ?int
|
||||
{
|
||||
return $this->fields->getVersion();
|
||||
}
|
||||
}
|
24
vendor/ramsey/uuid/src/Exception/BuilderNotFoundException.php
vendored
Normal file
24
vendor/ramsey/uuid/src/Exception/BuilderNotFoundException.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Exception;
|
||||
|
||||
use RuntimeException as PhpRuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that no suitable builder could be found
|
||||
*/
|
||||
class BuilderNotFoundException extends PhpRuntimeException implements UuidExceptionInterface
|
||||
{
|
||||
}
|
24
vendor/ramsey/uuid/src/Exception/DateTimeException.php
vendored
Normal file
24
vendor/ramsey/uuid/src/Exception/DateTimeException.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Exception;
|
||||
|
||||
use RuntimeException as PhpRuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the PHP DateTime extension encountered an exception/error
|
||||
*/
|
||||
class DateTimeException extends PhpRuntimeException implements UuidExceptionInterface
|
||||
{
|
||||
}
|
25
vendor/ramsey/uuid/src/Exception/DceSecurityException.php
vendored
Normal file
25
vendor/ramsey/uuid/src/Exception/DceSecurityException.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Exception;
|
||||
|
||||
use RuntimeException as PhpRuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown to indicate an exception occurred while dealing with DCE Security
|
||||
* (version 2) UUIDs
|
||||
*/
|
||||
class DceSecurityException extends PhpRuntimeException implements UuidExceptionInterface
|
||||
{
|
||||
}
|
24
vendor/ramsey/uuid/src/Exception/InvalidArgumentException.php
vendored
Normal file
24
vendor/ramsey/uuid/src/Exception/InvalidArgumentException.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Exception;
|
||||
|
||||
use InvalidArgumentException as PhpInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the argument received is not valid
|
||||
*/
|
||||
class InvalidArgumentException extends PhpInvalidArgumentException implements UuidExceptionInterface
|
||||
{
|
||||
}
|
24
vendor/ramsey/uuid/src/Exception/InvalidBytesException.php
vendored
Normal file
24
vendor/ramsey/uuid/src/Exception/InvalidBytesException.php
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Exception;
|
||||
|
||||
use RuntimeException as PhpRuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the bytes being operated on are invalid in some way
|
||||
*/
|
||||
class InvalidBytesException extends PhpRuntimeException implements UuidExceptionInterface
|
||||
{
|
||||
}
|
25
vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php
vendored
Normal file
25
vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Exception;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the string received is not a valid UUID
|
||||
*
|
||||
* The InvalidArgumentException that this extends is the ramsey/uuid version
|
||||
* of this exception. It exists in the same namespace as this class.
|
||||
*/
|
||||
class InvalidUuidStringException extends InvalidArgumentException implements UuidExceptionInterface
|
||||
{
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user