| @@ 19-37 (lines=19) @@ | ||
| 16 | ||
| 17 | protected $voiceVerifyRunning = false; |
|
| 18 | ||
| 19 | public function sendSms($tempId, $to, array $tempData, $content) |
|
| 20 | { |
|
| 21 | if (!is_callable($this->sendSms)) { |
|
| 22 | $name = $this->name; |
|
| 23 | throw new PhpSmsException("Please give parasitic agent [$name] a callable param named `sendSms` by enable config."); |
|
| 24 | } |
|
| 25 | if (!$this->sendSmsRunning) { |
|
| 26 | $this->sendSmsRunning = true; |
|
| 27 | try { |
|
| 28 | call_user_func_array($this->sendSms, [$this, $tempId, $to, $tempData, $content]); |
|
| 29 | } catch (\Exception $e) { |
|
| 30 | $this->sendSmsRunning = false; |
|
| 31 | throw $e; |
|
| 32 | } |
|
| 33 | $this->sendSmsRunning = false; |
|
| 34 | } else { |
|
| 35 | throw new PhpSmsException('Please do not use `$agent->sendSms()` in closure.'); |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| 39 | public function sendContentSms($to, $content) |
|
| 40 | { |
|
| @@ 49-67 (lines=19) @@ | ||
| 46 | throw new PhpSmsException('Parasitic agent does not support `sendTemplateSms` method.'); |
|
| 47 | } |
|
| 48 | ||
| 49 | public function voiceVerify($to, $code) |
|
| 50 | { |
|
| 51 | if (!is_callable($this->voiceVerify)) { |
|
| 52 | $name = $this->name; |
|
| 53 | throw new PhpSmsException("Please give parasitic agent [$name] a callable param named `voiceVerify` by enable config."); |
|
| 54 | } |
|
| 55 | if (!$this->voiceVerifyRunning) { |
|
| 56 | $this->voiceVerifyRunning = true; |
|
| 57 | try { |
|
| 58 | call_user_func_array($this->voiceVerify, [$this, $to, $code]); |
|
| 59 | } catch (\Exception $e) { |
|
| 60 | $this->voiceVerifyRunning = false; |
|
| 61 | throw $e; |
|
| 62 | } |
|
| 63 | $this->voiceVerifyRunning = false; |
|
| 64 | } else { |
|
| 65 | throw new PhpSmsException('Please do not use `$agent->voiceVerify()` in closure.'); |
|
| 66 | } |
|
| 67 | } |
|
| 68 | } |
|
| 69 | ||