<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Util; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\Response; use Module\Vendor\Provider\SmsSender\SmsSenderProvider; class SmsUtil { public static function calcNumber($OfwYj) { return ceil(mb_strlen($OfwYj) / 67); } public static function parseContent($sHXTa, $uA2kT = array()) { goto CGfLE; CGfLE: $XBR1_ = array(); goto bbXHa; bbXHa: $dBSSL = array(); goto m5IGd; m5IGd: foreach ($uA2kT as $ynzcc => $nfRLq) { $XBR1_[] = '{' . $ynzcc . '}'; $dBSSL[] = $nfRLq; } goto vSx7_; vSx7_: return str_replace($XBR1_, $dBSSL, $sHXTa); goto oPwva; oPwva: } public static function parseTemplateParam($sHXTa) { preg_match_all('/\\{(.*?)\\}/', $sHXTa, $QuDiu); return $QuDiu[1]; } public static function replaceTemplate($sHXTa, $ZOWC5 = '#') { goto VdqoS; VdqoS: $quZRe = self::parseTemplateParam($sHXTa); goto hqR23; hqR23: foreach ($quZRe as $nfRLq) { if (is_string($ZOWC5)) { $sHXTa = str_replace('{' . $nfRLq . '}', $ZOWC5 . $nfRLq . $ZOWC5, $sHXTa); } else { $sHXTa = str_replace('{' . $nfRLq . '}', call_user_func($ZOWC5, $nfRLq), $sHXTa); } } goto P5WlD; P5WlD: return $sHXTa; goto FUpbb; FUpbb: } public static function templates() { $e2gbd = array(array('name' => 'verify', 'title' => '验证码', 'desc' => '验证码模板变量为 code')); return $e2gbd; } public static function send($G3YVc, $sHXTa, $CJiXs = array()) { goto CbPNY; CbPNY: $yzKqK = app()->config->get('SmsSenderProvider'); goto kkSH_; kkSH_: BizException::throwsIfEmpty('短信发送未设置', $yzKqK); goto L8uFF; L8uFF: $om_hh = SmsSenderProvider::get($yzKqK)->send($G3YVc, $sHXTa, $CJiXs); goto tUBuZ; tUBuZ: BizException::throwsIfResponseError($om_hh); goto L31vu; L31vu: return Response::generateSuccess(); goto hOQL4; hOQL4: } }