PHP Class Toplan\PhpSms\Sms

Afficher le fichier Open project: toplan/phpsms Class Usage Examples

Protected Properties

Свойство Type Description
$_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.

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
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.

Method Details

__call() public méthode

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

__callStatic() public static méthode

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

__construct() public méthode

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

__sleep() public méthode

Serialize magic method.
public __sleep ( ) : array
Résultat array

__wakeup() public méthode

Deserialize magic method.
public __wakeup ( )

agent() public méthode

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

bootstrap() public static méthode

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

cleanConfig() public static méthode

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

cleanScheme() public static méthode

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() public static méthode

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
Résultat array

configuration() protected static méthode

Configuration.
protected static configuration ( )

content() public méthode

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

data() public méthode

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

getAgent() public static méthode

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
Résultat mixed

getData() public méthode

Get all the data of SMS/voice verify.
public getData ( null | string $name = null ) : mixed
$name null | string
Résultat mixed

getSerializer() protected static méthode

Get a closure serializer.
protected static getSerializer ( ) : SuperClosure\Serializer
Résultat SuperClosure\Serializer

getTask() public static méthode

Get or generate a balancing task instance for send SMS/voice verify.
public static getTask ( ) : Toplan\TaskBalance\Task
Résultat Toplan\TaskBalance\Task

hasAgent() public static méthode

Whether to has specified agent.
public static hasAgent ( string $name ) : boolean
$name string
Résultat boolean

initAgentsConfig() protected static méthode

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

initScheme() protected static méthode

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

initTask() protected static méthode

Initialize the task.
protected static initTask ( )

make() public static méthode

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
Résultat Sms

modifyConfig() protected static méthode

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

modifyScheme() protected static méthode

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

parseScheme() protected static méthode

解析代理器的数组模式的调度配置
protected static parseScheme ( array $options ) : array
$options array
Résultat array

push() public méthode

Push to the queue by a custom method.
public push ( ) : mixed
Résultat mixed

queue() public static méthode

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
Résultat boolean

reinstallHandlers() protected static méthode

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

scheme() public static méthode

Set or get the dispatch scheme of agent by name.
public static scheme ( mixed $name = null, mixed $scheme = null ) : mixed
$name mixed
$scheme mixed
Résultat mixed

send() public méthode

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
Résultat mixed

serializeHandlers() protected static méthode

Serialize the hooks` handlers of balancing task
protected static serializeHandlers ( ) : array
Résultat array

serializeOrDeserializeClosureAndReplace() protected static méthode

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

serializeOrDeserializeScheme() protected static méthode

Serialize or deserialize the agent use scheme.
protected static serializeOrDeserializeScheme ( array $scheme ) : array
$scheme array
Résultat array

taskInitialized() protected static méthode

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

template() public méthode

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

to() public méthode

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

validateAgentName() protected static méthode

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

validateConfig() protected static méthode

validate configuration.
protected static validateConfig ( )

voice() public static méthode

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
Résultat Sms

Property Details

$_status_before_enqueue_ protected_oe property

Status container, store some configuration information before serialize current instance(before enqueue).
protected array $_status_before_enqueue_
Résultat array

$agents protected_oe static_oe property

The instances of Agent.
protected static array $agents
Résultat array

$agentsConfig protected_oe static_oe property

The configuration information of agents.
protected static array $agentsConfig
Résultat array

$availableHooks protected_oe static_oe property

The available hooks for balancing task.
protected static array $availableHooks
Résultat array

$enableQueue protected_oe static_oe property

Whether to use the queue.
protected static bool $enableQueue
Résultat boolean

$firstAgent protected_oe property

The name of first agent.
protected string|null $firstAgent
Résultat string | null

$howToUseQueue protected_oe static_oe property

How to use the queue.
protected static Closure $howToUseQueue
Résultat Closure

$pushedToQueue protected_oe property

Whether the current instance has already pushed to the queue system.
protected bool $pushedToQueue
Résultat boolean

$scheme protected_oe static_oe property

example: [ 'Agent1' => '10 backup', 'Agent2' => '20 backup', ]
protected static array $scheme
Résultat array

$serializer protected_oe static_oe property

An instance of class [SuperClosure\Serializer] for serialize closure objects.
protected static Serializer,SuperClosure $serializer
Résultat SuperClosure\Serializer

$smsData protected_oe property

The data container of SMS/voice verify.
protected array $smsData
Résultat array