PHP Класс Toplan\PhpSms\Sms

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_status_before_enqueue_ array Status container, store some configuration information before serialize current instance(before enqueue).
$agents array The instances of Agent.
$agentsConfig array The configuration information of agents.
$availableHooks array The available hooks for balancing task.
$enableQueue boolean Whether to use the queue.
$firstAgent string | null The name of first agent.
$howToUseQueue Closure How to use the queue.
$pushedToQueue boolean Whether the current instance has already pushed to the queue system.
$scheme array example: [ 'Agent1' => '10 backup', 'Agent2' => '20 backup', ]
$serializer SuperClosure\Serializer An instance of class [SuperClosure\Serializer] for serialize closure objects.
$smsData array The data container of SMS/voice verify.

Открытые методы

Метод Описание
__call ( string $name, array $args ) Overload method.
__callStatic ( string $name, array $args ) Overload static method.
__construct ( boolean $autoBoot = true ) Constructor
__sleep ( ) : array Serialize magic method.
__wakeup ( ) Deserialize magic method.
agent ( string $name ) Set the first agent by name.
bootstrap ( ) Boot balancing task for send SMS/voice verify.
cleanConfig ( ) Tear down all the configuration information of agent.
cleanScheme ( ) Tear down agent use scheme and prepare to create and start a new balancing task, so before do it must destroy old task instance.
config ( mixed $name = null, mixed $config = null, boolean $override = false ) : array Set or get configuration information by agent name.
content ( string $content ) Set the content for content SMS.
data ( array $data ) Set the template data for template SMS.
getAgent ( string $name ) : mixed Get a sms agent instance by agent name, if null, will try to create a new agent instance.
getData ( null | string $name = null ) : mixed Get all the data of SMS/voice verify.
getTask ( ) : Toplan\TaskBalance\Task Get or generate a balancing task instance for send SMS/voice verify.
hasAgent ( string $name ) : boolean Whether to has specified agent.
make ( mixed $agentName = null, mixed $tempId = null ) : Sms Create a sms instance send SMS, your can also set SMS templates or content at the same time.
push ( ) : mixed Push to the queue by a custom method.
queue ( mixed $enable = null, mixed $handler = null ) : boolean Set whether to use the queue system, and define how to use it.
scheme ( mixed $name = null, mixed $scheme = null ) : mixed Set or get the dispatch scheme of agent by name.
send ( boolean $immediately = false ) : mixed Start send SMS/voice verify.
template ( mixed $name, mixed $tempId = null ) Set the template id for template SMS.
to ( string $mobile ) Set the recipient`s mobile number.
voice ( integer | string | null $code = null ) : Sms Create a sms instance send voice verify, your can also set verify code at the same time.

Защищенные методы

Метод Описание
configuration ( ) Configuration.
getSerializer ( ) : SuperClosure\Serializer Get a closure serializer.
initAgentsConfig ( array $agents, array &$config ) Try to initialize the specified agents` configuration information.
initScheme ( array &$config ) Try to read the dispatch scheme of agent from config file.
initTask ( ) Initialize the task.
modifyConfig ( string $key, array $value ) Modify the configuration information of agent by name.
modifyScheme ( $key, $value ) Modify the dispatch scheme of agent by name.
parseScheme ( array $options ) : array Parsing the dispatch scheme.
reinstallHandlers ( array $handlers ) Reinstall hooks` handlers for balancing task.
serializeHandlers ( ) : array Serialize the hooks` handlers of balancing task
serializeOrDeserializeClosureAndReplace ( array &$options, integer | string $key ) Serialize/deserialize the specified closure and replace the origin value.
serializeOrDeserializeScheme ( array $scheme ) : array Serialize or deserialize the agent use scheme.
taskInitialized ( ) : boolean Whether task initialized.
validateAgentName ( string $name ) Validate the agent name.
validateConfig ( ) validate configuration.

Описание методов

__call() публичный Метод

Overload method.
public __call ( string $name, array $args )
$name string
$args array

__callStatic() публичный статический Метод

Overload static method.
public static __callStatic ( string $name, array $args )
$name string
$args array

__construct() публичный Метод

Constructor
public __construct ( boolean $autoBoot = true )
$autoBoot boolean

__sleep() публичный Метод

Serialize magic method.
public __sleep ( ) : array
Результат array

__wakeup() публичный Метод

Deserialize magic method.
public __wakeup ( )

agent() публичный Метод

Set the first agent by name.
public agent ( string $name )
$name string

bootstrap() публичный статический Метод

Boot balancing task for send SMS/voice verify.
public static bootstrap ( )

cleanConfig() публичный статический Метод

Tear down all the configuration information of agent.
public static cleanConfig ( )

cleanScheme() публичный статический Метод

Tear down agent use scheme and prepare to create and start a new balancing task, so before do it must destroy old task instance.
public static cleanScheme ( )

config() публичный статический Метод

Set or get configuration information by agent name.
public static config ( mixed $name = null, mixed $config = null, boolean $override = false ) : array
$name mixed
$config mixed
$override boolean
Результат array

configuration() защищенный статический Метод

Configuration.
protected static configuration ( )

content() публичный Метод

Set the content for content SMS.
public content ( string $content )
$content string

data() публичный Метод

Set the template data for template SMS.
public data ( array $data )
$data array

getAgent() публичный статический Метод

Get a sms agent instance by agent name, if null, will try to create a new agent instance.
public static getAgent ( string $name ) : mixed
$name string
Результат mixed

getData() публичный Метод

Get all the data of SMS/voice verify.
public getData ( null | string $name = null ) : mixed
$name null | string
Результат mixed

getSerializer() защищенный статический Метод

Get a closure serializer.
protected static getSerializer ( ) : SuperClosure\Serializer
Результат SuperClosure\Serializer

getTask() публичный статический Метод

Get or generate a balancing task instance for send SMS/voice verify.
public static getTask ( ) : Toplan\TaskBalance\Task
Результат Toplan\TaskBalance\Task

hasAgent() публичный статический Метод

Whether to has specified agent.
public static hasAgent ( string $name ) : boolean
$name string
Результат boolean

initAgentsConfig() защищенный статический Метод

Try to initialize the specified agents` configuration information.
protected static initAgentsConfig ( array $agents, array &$config )
$agents array
$config array

initScheme() защищенный статический Метод

Try to read the dispatch scheme of agent from config file.
protected static initScheme ( array &$config )
$config array

initTask() защищенный статический Метод

Initialize the task.
protected static initTask ( )

make() публичный статический Метод

Create a sms instance send SMS, your can also set SMS templates or content at the same time.
public static make ( mixed $agentName = null, mixed $tempId = null ) : Sms
$agentName mixed
$tempId mixed
Результат Sms

modifyConfig() защищенный статический Метод

Modify the configuration information of agent by name.
protected static modifyConfig ( string $key, array $value )
$key string
$value array

modifyScheme() защищенный статический Метод

Modify the dispatch scheme of agent by name.
protected static modifyScheme ( $key, $value )
$key
$value

parseScheme() защищенный статический Метод

解析代理器的数组模式的调度配置
protected static parseScheme ( array $options ) : array
$options array
Результат array

push() публичный Метод

Push to the queue by a custom method.
public push ( ) : mixed
Результат mixed

queue() публичный статический Метод

Set whether to use the queue system, and define how to use it.
public static queue ( mixed $enable = null, mixed $handler = null ) : boolean
$enable mixed
$handler mixed
Результат boolean

reinstallHandlers() защищенный статический Метод

Reinstall hooks` handlers for balancing task.
protected static reinstallHandlers ( array $handlers )
$handlers array

scheme() публичный статический Метод

Set or get the dispatch scheme of agent by name.
public static scheme ( mixed $name = null, mixed $scheme = null ) : mixed
$name mixed
$scheme mixed
Результат mixed

send() публичный Метод

If give a true parameter, this system will immediately start request to send SMS/voice verify whatever whether to use the queue. if you are already pushed sms instance to the queue, you can recall the method send() in queue system without true parameter, so this mechanism in order to make you convenient use the method send() in queue system.
public send ( boolean $immediately = false ) : mixed
$immediately boolean
Результат mixed

serializeHandlers() защищенный статический Метод

Serialize the hooks` handlers of balancing task
protected static serializeHandlers ( ) : array
Результат array

serializeOrDeserializeClosureAndReplace() защищенный статический Метод

Serialize/deserialize the specified closure and replace the origin value.
protected static serializeOrDeserializeClosureAndReplace ( array &$options, integer | string $key )
$options array
$key integer | string

serializeOrDeserializeScheme() защищенный статический Метод

Serialize or deserialize the agent use scheme.
protected static serializeOrDeserializeScheme ( array $scheme ) : array
$scheme array
Результат array

taskInitialized() защищенный статический Метод

Note: 判断drivers是否为空不能用'empty',因为在TaskBalance库的中Task类的drivers属性是受保护的(不可访问), 虽然通过魔术方法可以获取到其值,但在其目前版本(v0.4.2)其内部却并没有使用'__isset'魔术方法对'empty'或'isset'函数进行逻辑补救.
protected static taskInitialized ( ) : boolean
Результат boolean

template() публичный Метод

Set the template id for template SMS.
public template ( mixed $name, mixed $tempId = null )
$name mixed
$tempId mixed

to() публичный Метод

Set the recipient`s mobile number.
public to ( string $mobile )
$mobile string

validateAgentName() защищенный статический Метод

Agent name must be a string, but not be a number string
protected static validateAgentName ( string $name )
$name string

validateConfig() защищенный статический Метод

validate configuration.
protected static validateConfig ( )

voice() публичный статический Метод

Create a sms instance send voice verify, your can also set verify code at the same time.
public static voice ( integer | string | null $code = null ) : Sms
$code integer | string | null
Результат Sms

Описание свойств

$_status_before_enqueue_ защищенное свойство

Status container, store some configuration information before serialize current instance(before enqueue).
protected array $_status_before_enqueue_
Результат array

$agents защищенное статическое свойство

The instances of Agent.
protected static array $agents
Результат array

$agentsConfig защищенное статическое свойство

The configuration information of agents.
protected static array $agentsConfig
Результат array

$availableHooks защищенное статическое свойство

The available hooks for balancing task.
protected static array $availableHooks
Результат array

$enableQueue защищенное статическое свойство

Whether to use the queue.
protected static bool $enableQueue
Результат boolean

$firstAgent защищенное свойство

The name of first agent.
protected string|null $firstAgent
Результат string | null

$howToUseQueue защищенное статическое свойство

How to use the queue.
protected static Closure $howToUseQueue
Результат Closure

$pushedToQueue защищенное свойство

Whether the current instance has already pushed to the queue system.
protected bool $pushedToQueue
Результат boolean

$scheme защищенное статическое свойство

example: [ 'Agent1' => '10 backup', 'Agent2' => '20 backup', ]
protected static array $scheme
Результат array

$serializer защищенное статическое свойство

An instance of class [SuperClosure\Serializer] for serialize closure objects.
protected static Serializer,SuperClosure $serializer
Результат SuperClosure\Serializer

$smsData защищенное свойство

The data container of SMS/voice verify.
protected array $smsData
Результат array