<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Str; class StrUtil { public static function mask($e7jXr, $vChIS = null, $D5XqK = null, $GgTDf = '*') { goto MZjT0; Hlqbi: if ($D5XqK >= $eEZzQ - 1) { $D5XqK = $eEZzQ - 1; } goto nb7Ie; MZjT0: $eEZzQ = mb_strlen($e7jXr); goto ik91A; Uhkh8: if (null == $D5XqK) { $D5XqK = $vChIS + floor($eEZzQ / 2); } goto Zwckg; NoMiM: return $djIVf; goto WHMTu; O8tpi: if ($D5XqK < $eEZzQ - 1) { $djIVf .= mb_substr($e7jXr, $D5XqK + 1); } goto NoMiM; JY_RN: if ($vChIS > 0) { $djIVf .= mb_substr($e7jXr, 0, $vChIS); } goto MXvRG; Zwckg: if ($vChIS < 0) { $vChIS = 0; } goto Hlqbi; MXvRG: $djIVf .= str_repeat($GgTDf, $D5XqK - $vChIS + 1); goto O8tpi; nb7Ie: $djIVf = ''; goto JY_RN; ik91A: if (null == $vChIS) { $vChIS = floor($eEZzQ / 2); } goto Uhkh8; WHMTu: } public static function passwordStrength($f8snf) { goto NM6Ti; B82Rn: if (!empty($f8snf)) { $qKDZL++; } goto fOrga; ZAWe7: return $qKDZL; goto AN4vo; AFfP2: if (!empty($f8snf)) { $qKDZL++; } goto Prb_Y; fOrga: $f8snf = preg_replace('/[A-Z]+/', '', $f8snf); goto edNzQ; NM6Ti: $qKDZL = 0; goto CYPCf; YX8J5: $f8snf = preg_replace('/\\d+/', '', $f8snf); goto AFfP2; edNzQ: if (!empty($f8snf)) { $qKDZL++; } goto ZAWe7; Prb_Y: $f8snf = preg_replace('/[a-z]+/', '', $f8snf); goto B82Rn; CYPCf: if (!empty($f8snf)) { $qKDZL++; } goto YX8J5; AN4vo: } public static function camelize($jYvBU, $pk3fF = '_') { $jYvBU = $pk3fF . str_replace($pk3fF, ' ', strtolower($jYvBU)); return ltrim(str_replace(' ', '', ucwords($jYvBU)), $pk3fF); } public static function uncamelize($Pm2Vk, $pk3fF = '_') { return strtolower(preg_replace('/([a-z])([A-Z])/', '$1' . $pk3fF . '$2', $Pm2Vk)); } public static function startWith($oKam6, $KHwa7) { foreach ((array) $KHwa7 as $BI9Qj) { if ($BI9Qj != '' && mb_strpos($oKam6, $BI9Qj) === 0) { return true; } } return false; } public static function filterSpecialChars($mdHu1) { $c9B3Y = array('​', '‌', '‍'); return str_replace($c9B3Y, '', $mdHu1); } public static function limit($d1mrX, $XzVT3 = 100, $R96Y0 = '...') { return Str::limit($d1mrX, $XzVT3, $R96Y0); } public static function mbLimit($d1mrX, $XzVT3) { return Str::limit($d1mrX, $XzVT3, ''); } public static function mbLimitChars($d1mrX, $XzVT3) { goto izT1g; zMljl: return $AvSl6; goto ndgTL; S34rQ: $BrF3H = 0; goto hU4fi; ZCYqZ: foreach ($c9B3Y as $KJKL7) { goto yM0nW; yM0nW: $BrF3H += strlen($KJKL7); goto HCB4L; fqxA5: $AvSl6 .= $KJKL7; goto PEK13; HCB4L: if ($BrF3H > $XzVT3) { break; } goto fqxA5; PEK13: } goto zMljl; izT1g: $c9B3Y = mb_str_split($d1mrX, 1, 'UTF-8'); goto S34rQ; hU4fi: $AvSl6 = ''; goto ZCYqZ; ndgTL: } public static function mbLength($d1mrX) { if (empty($d1mrX)) { return 0; } return intval(mb_strlen($d1mrX, 'UTF-8')); } public static function mbLengthGt($d1mrX, $XzVT3) { return self::mbLength($d1mrX) > $XzVT3; } public static function mbWordwrap($jFNXP, $jy3JI = 75, $qyonS = '
') { goto VSL02; VIwjk: $LFzZs = ''; goto EYtO1; VSL02: if ($jFNXP === '') { return ''; } goto r0N6_; EYtO1: $UnmsT = $Sl0tJ = 0; goto Dmv46; m4BpP: return $LFzZs; goto oI2Fp; ApxYQ: if ($UnmsT !== $ugfUq) { $LFzZs .= mb_substr($jFNXP, $UnmsT, $ugfUq - $UnmsT); } goto m4BpP; gfrmW: $itkDl = mb_strlen($jFNXP); goto cgony; r0N6_: if (strlen($jFNXP) === mb_strlen($jFNXP)) { return wordwrap($jFNXP, $jy3JI, $qyonS, true); } goto gfrmW; Dmv46: for ($ugfUq = 0; $ugfUq < $itkDl; $ugfUq++) { $KJKL7 = mb_substr($jFNXP, $ugfUq, 1); $iVZxe = $KJKL7; if ($xLaCp !== 1) { $iVZxe = mb_substr($jFNXP, $ugfUq, $xLaCp); } if ($iVZxe === $qyonS) { goto VDEVj; VDEVj: $LFzZs .= mb_substr($jFNXP, $UnmsT, $ugfUq - $UnmsT + $xLaCp); goto ef1Qy; ef1Qy: $ugfUq += $xLaCp - 1; goto MdltB; MdltB: $UnmsT = $Sl0tJ = $ugfUq + 1; goto oRROC; oRROC: continue; goto doobN; doobN: } if ($KJKL7 === ' ') { goto Ot9H6; Ak2NK: continue; goto LLiBs; Irlc1: $Sl0tJ = $ugfUq; goto Ak2NK; Ot9H6: if ($ugfUq - $UnmsT >= $jy3JI) { $LFzZs .= mb_substr($jFNXP, $UnmsT, $ugfUq - $UnmsT) . $qyonS; $UnmsT = $ugfUq + 1; } goto Irlc1; LLiBs: } if ($ugfUq - $UnmsT >= $jy3JI && $UnmsT >= $Sl0tJ) { goto YK24Z; YK24Z: $LFzZs .= mb_substr($jFNXP, $UnmsT, $ugfUq - $UnmsT) . $qyonS; goto Z_rJu; Z_rJu: $UnmsT = $Sl0tJ = $ugfUq; goto Xunvj; Xunvj: continue; goto UACCE; UACCE: } if ($ugfUq - $UnmsT >= $jy3JI && $UnmsT < $Sl0tJ) { goto SLPjJ; qMaJx: continue; goto NBB6e; F04Z9: $UnmsT = $Sl0tJ = $Sl0tJ + 1; goto qMaJx; SLPjJ: $LFzZs .= mb_substr($jFNXP, $UnmsT, $Sl0tJ - $UnmsT) . $qyonS; goto F04Z9; NBB6e: } } goto ApxYQ; cgony: $xLaCp = mb_strlen($qyonS); goto VIwjk; oI2Fp: } public static function split($d1mrX, $bYgxs = ',', $VXKEE = array('，', ';', '；')) { goto MJcFN; MJcFN: $d1mrX = str_replace($VXKEE, $bYgxs, $d1mrX); goto Iz68E; JOneH: return $QX8nj; goto UmtHZ; Iz68E: $QX8nj = explode($bYgxs, $d1mrX); goto gfzlF; gfzlF: $QX8nj = array_map('trim', $QX8nj); goto Bd56N; Bd56N: $QX8nj = array_filter($QX8nj); goto JOneH; UmtHZ: } public static function wordSplit($LTC5O) { if (modstart_module_enabled('WordSpliter')) { $KHn4u = \Module\WordSpliter\Util\WordSpliterUtil::cut($LTC5O); } else { preg_match_all('/[\\x{4e00}-\\x{9fa5}]|\\b[A-Za-z]+\\b/u', $LTC5O, $EbeBB); $KHn4u = array_filter($EbeBB[0]); } return $KHn4u; } }