| @@ 18-35 (lines=18) @@ | ||
| 15 | ||
| 16 | protected $voiceVerifyRunning = false; |
|
| 17 | ||
| 18 | public function sendSms($to, $content, $tempId, array $data) |
|
| 19 | { |
|
| 20 | if (!is_callable($this->sendSms)) { |
|
| 21 | throw new PhpSmsException('Expected the higher-order scheme option `sendSms` to be a closure.'); |
|
| 22 | } |
|
| 23 | if ($this->sendSmsRunning) { |
|
| 24 | throw new PhpSmsException('Do not call `$agent->sendSms()` in the closure.'); |
|
| 25 | } |
|
| 26 | $this->sendSmsRunning = true; |
|
| 27 | try { |
|
| 28 | call_user_func_array($this->sendSms, [$this, $to, $content, $tempId, $data]); |
|
| 29 | $this->sendSmsRunning = false; |
|
| 30 | } catch (\Exception $e) { |
|
| 31 | $this->sendSmsRunning = false; |
|
| 32 | ||
| 33 | throw $e; |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| 37 | public function voiceVerify($to, $code, $tempId, array $data) |
|
| 38 | { |
|
| @@ 37-54 (lines=18) @@ | ||
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| 37 | public function voiceVerify($to, $code, $tempId, array $data) |
|
| 38 | { |
|
| 39 | if (!is_callable($this->voiceVerify)) { |
|
| 40 | throw new PhpSmsException('Expected the higher-order scheme option `voiceVerify` to be a closure.'); |
|
| 41 | } |
|
| 42 | if ($this->voiceVerifyRunning) { |
|
| 43 | throw new PhpSmsException('Do not call `$agent->voiceVerify()` in the closure.'); |
|
| 44 | } |
|
| 45 | $this->voiceVerifyRunning = true; |
|
| 46 | try { |
|
| 47 | call_user_func_array($this->voiceVerify, [$this, $to, $code, $tempId, $data]); |
|
| 48 | $this->voiceVerifyRunning = false; |
|
| 49 | } catch (\Exception $e) { |
|
| 50 | $this->voiceVerifyRunning = false; |
|
| 51 | ||
| 52 | throw $e; |
|
| 53 | } |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||