<?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($eTwx_) { return ceil(mb_strlen($eTwx_) / 67); } public static function parseContent($H09n_, $XoEfM = array()) { goto z4Ufr; HuWbK: $rh9_l = array(); goto alYYE; alYYE: foreach ($XoEfM as $JdFJR => $PSYn9) { $In71j[] = '{' . $JdFJR . '}'; $rh9_l[] = $PSYn9; } goto Ct_AU; Ct_AU: return str_replace($In71j, $rh9_l, $H09n_); goto vNOQo; z4Ufr: $In71j = array(); goto HuWbK; vNOQo: } public static function parseTemplateParam($H09n_) { preg_match_all('/\\{(.*?)\\}/', $H09n_, $Qie0V); return $Qie0V[1]; } public static function replaceTemplate($H09n_, $wEfav = '#') { goto KK1Jk; sp7IB: return $H09n_; goto Z0LsI; KK1Jk: $KJ3xr = self::parseTemplateParam($H09n_); goto gaujV; gaujV: foreach ($KJ3xr as $PSYn9) { if (is_string($wEfav)) { $H09n_ = str_replace('{' . $PSYn9 . '}', $wEfav . $PSYn9 . $wEfav, $H09n_); } else { $H09n_ = str_replace('{' . $PSYn9 . '}', call_user_func($wEfav, $PSYn9), $H09n_); } } goto sp7IB; Z0LsI: } public static function templates() { $CzHKS = array(array('name' => 'verify', 'title' => '验证码', 'desc' => '验证码模板变量为 code')); return $CzHKS; } public static function send($lF49t, $H09n_, $JKXDQ = array()) { goto Ph0T4; i2QdW: return Response::generateSuccess(); goto mgrMM; Ph0T4: $sefXk = app()->config->get('SmsSenderProvider'); goto MDGTW; AGrqs: $Gs3Xd = SmsSenderProvider::get($sefXk)->send($lF49t, $H09n_, $JKXDQ); goto R_D0v; MDGTW: BizException::throwsIfEmpty('短信发送未设置', $sefXk); goto AGrqs; R_D0v: BizException::throwsIfResponseError($Gs3Xd); goto i2QdW; mgrMM: } }