PHP Class Toplan\Sms\SmsManager

Afficher le fichier Open project: toplan/laravel-sms Class Usage Examples

Protected Properties

Свойство Type Description
$input array 客户端数据
$state array 发送状态
$storage Toplan\Sms\Storage 存储器
$token string | null Access Token

Méthodes publiques

Méthode Description
__construct ( string | null $token = null, array $input = [] ) Constructor
forgetRule ( string $field, string | null $name = null ) 从存储器中删除指定字段的指定名称的动态验证规则
forgetRules ( string $field ) : array 从存储中获取指定字段的所有验证规则
forgetState ( ) 从存储器中删除发送状态
generateResult ( boolean $pass, string $type, string $message = '', array $data = [] ) : array 合成结果数组
getCanResendTime ( ) : integer 从存储器中获取可再次发送的截止时间
input ( string | integer | null $key = null, mixed $default = null ) : mixed 获取客户端数据
pathOfUrl ( string $url, Closure $onError = null ) : string 获取路径中的path部分
requestVerifySms ( ) : array 请求验证码短信
requestVoiceVerify ( ) : array 请求语音验证码
retrieveAllData ( ) : array 从存储器中获取用户的所有数据
retrieveRule ( string $field, string | null $name = null ) : string | null 从存储器中获取指定字段的指定名称的动态验证规则
retrieveRules ( string $field ) : array 从存储中获取指定字段的所有验证规则
retrieveState ( string | null $name = null ) : array 从存储器中获取发送状态
setCanResendAfter ( integer $interval ) : integer 设置多少秒后才能再次请求
state ( string | integer | null $key = null, mixed $default = null ) : mixed 获取当前的发送状态(非持久化的)
storeRule ( string $field, string $name, string | null $rule = null ) 存储指定字段的指定名称的动态验证规则
updateState ( string | array $name, mixed $value = null ) 更新发送状态
validateFields ( mixed $input = null, Closure $validation = null ) : array 验证数据
validateSendable ( ) : array 验证是否可发送
vsprintf ( string $template, array $data, Closure $onError = null ) : string 根据模版和数据合成字符串

Méthodes protégées

Méthode Description
generateCode ( integer | null $length = null, string | null $characters = null ) : string 根据配置文件中的长度生成验证码
generateKey ( ) : string 生成key
generateSmsContent ( string $code, integer $minutes ) : string 生成验证码短信通用内容
generateTemplateData ( string $code, integer $minutes, string $type ) : array 生成模版数据
getCodeValidMinutes ( ) : integer 从配置文件获取验证码有效时间(分钟)
getFields ( ) : array 获取可验证的字段
getInterval ( ) : integer 从配置文件获取可再次请求的最小时间间隔(秒)
getMobileField ( ) : string 获取手机号的字段名
getNameOfDefaultStaticRule ( string $field ) : string 获取指定字段的默认静态规则的名称
getNotifyMessage ( string $name ) : string 从配置文件获取提示信息
getRealRuleByName ( string $field, string $ruleName ) : string 根据规则名获取真实的验证规则
getStaticRule ( $field, $ruleName ) : string | null 获取指定字段的指定名称的静态验证规则
getStorageClassName ( ) : string 获取存储器类名
getTemplatesByKey ( string $key ) : array 从配置信息中获取指定键名的所有模版id
getValidationConfigByField ( string $field ) : array 获取验证配置
reset ( ) 重置发送状态
storage ( ) : Toplan\Sms\Storage 获取存储器
storeState ( ) 存储发送状态
useRule ( string $field, string $name ) 设置指定字段使用的验证规则名称
usedRule ( string $field ) : string 获取设置指定字段使用的验证规则名称
validateFieldName ( $name ) 检查字段名称是否合法
verifyCode ( ) : string 生成待发生的验证码
whetherValidateFiled ( string $field ) : boolean 是否检查指定的数据

Method Details

__construct() public méthode

Constructor
public __construct ( string | null $token = null, array $input = [] )
$token string | null
$input array

forgetRule() public méthode

从存储器中删除指定字段的指定名称的动态验证规则
public forgetRule ( string $field, string | null $name = null )
$field string
$name string | null

forgetRules() public méthode

从存储中获取指定字段的所有验证规则
public forgetRules ( string $field ) : array
$field string
Résultat array

forgetState() public méthode

从存储器中删除发送状态
public forgetState ( )

generateCode() protected static méthode

根据配置文件中的长度生成验证码
protected static generateCode ( integer | null $length = null, string | null $characters = null ) : string
$length integer | null
$characters string | null
Résultat string

generateKey() protected méthode

生成key
protected generateKey ( ) : string
Résultat string

generateResult() public static méthode

合成结果数组
public static generateResult ( boolean $pass, string $type, string $message = '', array $data = [] ) : array
$pass boolean
$type string
$message string
$data array
Résultat array

generateSmsContent() protected méthode

生成验证码短信通用内容
protected generateSmsContent ( string $code, integer $minutes ) : string
$code string
$minutes integer
Résultat string

generateTemplateData() protected méthode

生成模版数据
protected generateTemplateData ( string $code, integer $minutes, string $type ) : array
$code string
$minutes integer
$type string
Résultat array

getCanResendTime() public méthode

从存储器中获取可再次发送的截止时间
public getCanResendTime ( ) : integer
Résultat integer

getCodeValidMinutes() protected static méthode

从配置文件获取验证码有效时间(分钟)
protected static getCodeValidMinutes ( ) : integer
Résultat integer

getFields() protected static méthode

获取可验证的字段
protected static getFields ( ) : array
Résultat array

getInterval() protected static méthode

从配置文件获取可再次请求的最小时间间隔(秒)
protected static getInterval ( ) : integer
Résultat integer

getMobileField() protected static méthode

获取手机号的字段名
protected static getMobileField ( ) : string
Résultat string

getNameOfDefaultStaticRule() protected static méthode

获取指定字段的默认静态规则的名称
protected static getNameOfDefaultStaticRule ( string $field ) : string
$field string
Résultat string

getNotifyMessage() protected static méthode

从配置文件获取提示信息
protected static getNotifyMessage ( string $name ) : string
$name string
Résultat string

getRealRuleByName() protected méthode

- 首先尝试使用指定名称的静态验证规则 - 其次尝试使用指定名称的动态验证规则 - 最后尝试使用配置文件中的默认静态验证规则
protected getRealRuleByName ( string $field, string $ruleName ) : string
$field string
$ruleName string
Résultat string

getStaticRule() protected static méthode

获取指定字段的指定名称的静态验证规则
protected static getStaticRule ( $field, $ruleName ) : string | null
$field
$ruleName
Résultat string | null

getStorageClassName() protected static méthode

获取存储器类名
protected static getStorageClassName ( ) : string
Résultat string

getTemplatesByKey() protected static méthode

从配置信息中获取指定键名的所有模版id
protected static getTemplatesByKey ( string $key ) : array
$key string
Résultat array

getValidationConfigByField() protected static méthode

获取验证配置
protected static getValidationConfigByField ( string $field ) : array
$field string
Résultat array

input() public méthode

获取客户端数据
public input ( string | integer | null $key = null, mixed $default = null ) : mixed
$key string | integer | null
$default mixed
Résultat mixed

pathOfUrl() public static méthode

获取路径中的path部分
public static pathOfUrl ( string $url, Closure $onError = null ) : string
$url string
$onError Closure
Résultat string

requestVerifySms() public méthode

请求验证码短信
public requestVerifySms ( ) : array
Résultat array

requestVoiceVerify() public méthode

请求语音验证码
public requestVoiceVerify ( ) : array
Résultat array

reset() protected méthode

重置发送状态
protected reset ( )

retrieveAllData() public méthode

从存储器中获取用户的所有数据
public retrieveAllData ( ) : array
Résultat array

retrieveRule() public méthode

从存储器中获取指定字段的指定名称的动态验证规则
public retrieveRule ( string $field, string | null $name = null ) : string | null
$field string
$name string | null
Résultat string | null

retrieveRules() public méthode

从存储中获取指定字段的所有验证规则
public retrieveRules ( string $field ) : array
$field string
Résultat array

retrieveState() public méthode

从存储器中获取发送状态
public retrieveState ( string | null $name = null ) : array
$name string | null
Résultat array

setCanResendAfter() public méthode

设置多少秒后才能再次请求
public setCanResendAfter ( integer $interval ) : integer
$interval integer
Résultat integer

state() public méthode

获取当前的发送状态(非持久化的)
public state ( string | integer | null $key = null, mixed $default = null ) : mixed
$key string | integer | null
$default mixed
Résultat mixed

storage() protected static méthode

获取存储器
protected static storage ( ) : Toplan\Sms\Storage
Résultat Toplan\Sms\Storage

storeRule() public méthode

存储指定字段的指定名称的动态验证规则
public storeRule ( string $field, string $name, string | null $rule = null )
$field string
$name string
$rule string | null

storeState() protected méthode

存储发送状态
protected storeState ( )

updateState() public méthode

更新发送状态
public updateState ( string | array $name, mixed $value = null )
$name string | array
$value mixed

useRule() protected méthode

设置指定字段使用的验证规则名称
protected useRule ( string $field, string $name )
$field string
$name string

usedRule() protected méthode

获取设置指定字段使用的验证规则名称
protected usedRule ( string $field ) : string
$field string
Résultat string

validateFieldName() protected static méthode

检查字段名称是否合法
protected static validateFieldName ( $name )
$name

validateFields() public méthode

验证数据
public validateFields ( mixed $input = null, Closure $validation = null ) : array
$input mixed
$validation Closure
Résultat array

validateSendable() public méthode

验证是否可发送
public validateSendable ( ) : array
Résultat array

verifyCode() protected méthode

生成待发生的验证码
protected verifyCode ( ) : string
Résultat string

vsprintf() public static méthode

根据模版和数据合成字符串
public static vsprintf ( string $template, array $data, Closure $onError = null ) : string
$template string
$data array
$onError Closure
Résultat string

whetherValidateFiled() protected static méthode

是否检查指定的数据
protected static whetherValidateFiled ( string $field ) : boolean
$field string
Résultat boolean

Property Details

$input protected_oe property

客户端数据
protected array $input
Résultat array

$state protected_oe property

发送状态
protected array $state
Résultat array

$storage protected_oe static_oe property

存储器
protected static Storage,Toplan\Sms $storage
Résultat Toplan\Sms\Storage

$token protected_oe property

Access Token
protected string|null $token
Résultat string | null