You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< ? php
namespace App\Support ;
use Illuminate\Support\Str ;
use Overtrue\Pinyin\Pinyin ;
/**
* 场馆后台账号:用户名可用馆名拼音缩写;密码必须随机生成,不可由馆名推算。
*/
final class VenueAdminCredentials
{
/**
* 由场馆名称得到拼音首字母缩写(小写、仅字母数字),仅用于用户名。
*/
public static function acronymFromVenueName ( string $name ) : string
{
$joined = Pinyin :: abbr ( $name ) -> join ( '' );
$joined = strtolower ( $joined );
$joined = preg_replace ( '/[^a-z0-9]/' , '' , $joined ) ? ? '' ;
return $joined !== '' ? $joined : 'v' ;
}
/**
* 随机强密码:每次不同,长度至少 12, 含大小写字母、数字与符号。
*/
public static function randomPassword ( int $length = 16 ) : string
{
$length = max ( 12 , $length );
return Str :: password ( $length , true , true , true , false );
}
}