@@ -19,19 +19,19 @@ abstract class StringHelper
1919 public static function regexVerify ($ value , $ rule ): bool
2020 {
2121 $ value = trim ($ value );
22- $ validate = array (
23- 'require ' => '/\S+/ ' ,
24- 'email ' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/ ' ,
22+ $ validate = [
23+ 'require ' => '/\S+/ ' ,
24+ 'email ' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/ ' ,
2525 // 'url' => '/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/',
26- 'url ' => '/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i ' ,
26+ 'url ' => '/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i ' ,
2727 'currency ' => '/^\d+(\.\d+)?$/ ' ,
2828 # 货币
29- 'number ' => '/^\d+$/ ' ,
30- 'zip ' => '/^\d{6}$/ ' ,
31- 'integer ' => '/^[-\+]?\d+$/ ' ,
32- 'double ' => '/^[-\+]?\d+(\.\d+)?$/ ' ,
33- 'english ' => '/^[A-Za-z]+$/ ' ,
34- ) ;
29+ 'number ' => '/^\d+$/ ' ,
30+ 'zip ' => '/^\d{6}$/ ' ,
31+ 'integer ' => '/^[-\+]?\d+$/ ' ,
32+ 'double ' => '/^[-\+]?\d+(\.\d+)?$/ ' ,
33+ 'english ' => '/^[A-Za-z]+$/ ' ,
34+ ] ;
3535
3636 // 检查是否有内置的正则表达式
3737 if (isset ($ validate [strtolower ($ rule )])) {
@@ -42,7 +42,7 @@ public static function regexVerify($value, $rule): bool
4242 }
4343
4444 /**
45- * @param $str
45+ * @param $str
4646 * @param string $encoding
4747 * @return bool|int
4848 */
@@ -107,8 +107,8 @@ public static function absLen($str): int
107107 * @from web
108108 * utf-8编码下截取中文字符串,参数可以参照substr函数
109109 * @param string $str 要进行截取的字符串
110- * @param int $start 要进行截取的开始位置,负数为反向截取
111- * @param int $end 要进行截取的长度
110+ * @param int $start 要进行截取的开始位置,负数为反向截取
111+ * @param int $end 要进行截取的长度
112112 * @return string
113113 */
114114 public static function utf8SubStr ($ str , $ start = 0 , $ end = null ): string
@@ -147,10 +147,10 @@ public static function utf8SubStr($str, $start = 0, $end = null): string
147147 * @from web
148148 * 中文截取,支持gb2312,gbk,utf-8,big5 *
149149 * @param string $str 要截取的字串
150- * @param int $start 截取起始位置
151- * @param int $length 截取长度
150+ * @param int $start 截取起始位置
151+ * @param int $length 截取长度
152152 * @param string $charset utf-8|gb2312|gbk|big5 编码
153- * @param bool $suffix 是否加尾缀
153+ * @param bool $suffix 是否加尾缀
154154 * @return string
155155 */
156156 public static function zhSubStr ($ str , $ start = 0 , $ length , $ charset = 'utf-8 ' , $ suffix = true ): string
@@ -185,7 +185,7 @@ public static function zhSubStr($str, $start = 0, $length, $charset = 'utf-8', $
185185
186186 /**
187187 * ********************** 生成一定长度的随机字符串函数 **********************
188- * @param $length - 随机字符串长度
188+ * @param $length - 随机字符串长度
189189 * @param array|string $param -
190190 * @internal param string $chars
191191 * @return string
@@ -196,7 +196,7 @@ public static function random($length, array $param = []): string
196196 $ param = \array_merge ([
197197 'prefix ' => '' ,
198198 'suffix ' => '' ,
199- 'chars ' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '
199+ 'chars ' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '
200200 ], $ param );
201201
202202 $ chars = $ param ['chars ' ];
@@ -238,7 +238,7 @@ public static function genUid(int $length = 7): string
238238
239239 /**
240240 * gen UUID
241- * @param int $version
241+ * @param int $version
242242 * @param null $node
243243 * @param null $ns
244244 * @return UUID
@@ -290,10 +290,10 @@ public static function strtoupper($str)
290290 }
291291
292292 /**
293- * @param $str
294- * @param $start
293+ * @param $str
294+ * @param $start
295295 * @param bool|false $length
296- * @param string $encoding
296+ * @param string $encoding
297297 * @return bool|string
298298 */
299299 public static function substr (string $ str , int $ start , int $ length = null , string $ encoding = 'utf-8 ' )
@@ -306,9 +306,9 @@ public static function substr(string $str, int $start, int $length = null, strin
306306 }
307307
308308 /**
309- * @param $str
310- * @param $find
311- * @param int $offset
309+ * @param $str
310+ * @param $find
311+ * @param int $offset
312312 * @param string $encoding
313313 * @return bool|int
314314 */
@@ -322,7 +322,7 @@ public static function strpos(string $str, string $find, int $offset = 0, string
322322 /**
323323 * @param string $str
324324 * @param string $find
325- * @param int $offset
325+ * @param int $offset
326326 * @param string $encoding
327327 * @return bool|int
328328 */
@@ -404,7 +404,7 @@ public static function split2Array(string $path, string $separator = '.'): array
404404 /**
405405 * Truncate strings
406406 * @param string $str
407- * @param int $max_length Max length
407+ * @param int $max_length Max length
408408 * @param string $suffix Suffix optional
409409 * @return string $str truncated
410410 */
@@ -423,8 +423,8 @@ public static function truncate($str, $max_length, $suffix = '...'): string
423423
424424 /**
425425 * 字符截断输出
426- * @param string $str
427- * @param int $start
426+ * @param string $str
427+ * @param int $start
428428 * @param null|int $length
429429 * @return string
430430 */
@@ -451,16 +451,16 @@ public static function truncate2(string $str, int $start, int $length = null): s
451451 /**
452452 * Copied from CakePHP String utility file
453453 * @param string $text
454- * @param int $length
455- * @param array $options
454+ * @param int $length
455+ * @param array $options
456456 * @return bool|string
457457 */
458- public static function truncate3 (string $ text , int $ length = 120 , array $ options = array () )
458+ public static function truncate3 (string $ text , int $ length = 120 , array $ options = [] )
459459 {
460460 $ default = [
461461 'ellipsis ' => '... ' ,
462- 'exact ' => true ,
463- 'html ' => true
462+ 'exact ' => true ,
463+ 'html ' => true
464464 ];
465465
466466 $ options = array_merge ($ default , $ options );
@@ -470,8 +470,8 @@ public static function truncate3(string $text, int $length = 120, array $options
470470
471471 /**
472472 * @var string $ellipsis
473- * @var bool $exact
474- * @var bool $html
473+ * @var bool $exact
474+ * @var bool $html
475475 */
476476
477477 if ($ html ) {
@@ -583,7 +583,7 @@ public static function truncate3(string $text, int $length = 120, array $options
583583 }
584584
585585 /**
586- * @param $str
586+ * @param $str
587587 * @param bool $upperFirstChar
588588 * @return mixed
589589 */
@@ -595,7 +595,7 @@ public static function toCamel(string $str, bool $upperFirstChar = false): strin
595595 /**
596596 * Translates a string with underscores into camel case (e.g. first_name -> firstName)
597597 * @prototype string public static function toCamelCase(string $str[, bool $capitalise_first_char = false])
598- * @param $str
598+ * @param $str
599599 * @param bool $upperFirstChar
600600 * @return mixed
601601 */
@@ -633,7 +633,7 @@ public static function toSnakeCase(string $str, string $sep = '_'): string
633633 /**
634634 * 驼峰式 <=> 下划线式
635635 * @param string $str [description]
636- * @param bool $toCamelCase
636+ * @param bool $toCamelCase
637637 * true : 驼峰式 => 下划线式
638638 * false : 驼峰式 <= 下划线式
639639 * @return string
@@ -664,7 +664,7 @@ public static function nameChange(string $str, bool $toCamelCase = true): string
664664
665665 /**
666666 * [format description]
667- * @param $str
667+ * @param $str
668668 * @param array $replaceParams 用于 str_replace('search','replace',$str )
669669 * @example
670670 * $replaceParams = [
@@ -726,7 +726,7 @@ public static function wordFormat($keyword): string
726726
727727 /**
728728 * 缩进格式化内容,去空白/注释
729- * @param $fileName
729+ * @param $fileName
730730 * @param int $type
731731 * @return mixed
732732 */
0 commit comments