<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Sms; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\Response; use Module\Vendor\Provider\SmsSender\SmsSenderProvider; class SmsUtil { public static function calcNumber($V0Dls) { return ceil(mb_strlen($V0Dls) / 67); } public static function parseContent($np9vN, $SG_3V = array()) { goto urMoa; A0ZPU: foreach ($SG_3V as $D5qRP => $qGgGl) { $GRwGo[] = '{' . $D5qRP . '}'; $oq1pp[] = $qGgGl; } goto yofMs; E0IYC: $oq1pp = array(); goto A0ZPU; yofMs: return str_replace($GRwGo, $oq1pp, $np9vN); goto oQXEJ; urMoa: $GRwGo = array(); goto E0IYC; oQXEJ: } public static function parseTemplateParam($np9vN) { preg_match_all('/\\{(.*?)\\}/', $np9vN, $YpeHe); return $YpeHe[1]; } public static function replaceTemplate($np9vN, $eWph9 = '#') { goto w9TwL; lFeRO: return $np9vN; goto H_3aU; w9TwL: $uxJUJ = self::parseTemplateParam($np9vN); goto u4Kis; u4Kis: foreach ($uxJUJ as $qGgGl) { if (is_string($eWph9)) { $np9vN = str_replace('{' . $qGgGl . '}', $eWph9 . $qGgGl . $eWph9, $np9vN); } else { $np9vN = str_replace('{' . $qGgGl . '}', call_user_func($eWph9, $qGgGl), $np9vN); } } goto lFeRO; H_3aU: } public static function templates() { $BC78I = array(array('name' => 'verify', 'title' => '验证码', 'desc' => '验证码模板变量为 code')); return $BC78I; } public static function send($ffJmI, $np9vN, $DlEFb = array()) { goto DWY2J; aAZwN: $ZrjxR = SmsSenderProvider::get($kHDkQ)->send($ffJmI, $np9vN, $DlEFb); goto AWQNk; AWQNk: BizException::throwsIfResponseError($ZrjxR); goto hi7ZI; hi7ZI: return Response::generateSuccess(); goto OQmuB; rqsVe: BizException::throwsIfEmpty('短信发送未设置', $kHDkQ); goto aAZwN; DWY2J: $kHDkQ = app()->config->get('SmsSenderProvider'); goto rqsVe; OQmuB: } }