Skip to content

Commit 2b6a916

Browse files
committed
update... some modify
1 parent 7606f58 commit 2b6a916

File tree

3 files changed

+136
-148
lines changed

3 files changed

+136
-148
lines changed

example/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@
7070
$valid->all(),
7171
$valid->getErrors()
7272
);
73-
*/
73+
*/

src/StrHelper.php

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class StrHelper
1717
* @param string $rule 验证规则 require email url currency number integer english
1818
* @return boolean
1919
*/
20-
static public function regexVerify($value,$rule)
20+
public static function regexVerify($value,$rule)
2121
{
2222
$value = trim($value);
2323
$validate = array(
@@ -46,7 +46,7 @@ static public function regexVerify($value,$rule)
4646
* @param $string
4747
* @return bool
4848
*/
49-
static public function isVarName($string)
49+
public static function isVarName($string)
5050
{
5151
return preg_match('@^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*@i', $string)===1;
5252
}
@@ -56,21 +56,19 @@ static public function isVarName($string)
5656
* @param [type] $str
5757
* @return int|string [type]
5858
*/
59-
static public function length($str)
59+
public static function length($str)
6060
{
61-
6261
if (empty($str)){
6362
return '0';
6463
}
6564

66-
if ((string)$str=='0'){
65+
if ((string)$str === '0'){
6766
return '1';
6867
}
6968

7069
if (function_exists('mb_strlen')){
7170
return mb_strlen($str,'utf-8');
72-
}
73-
else {
71+
} else {
7472
preg_match_all("/./u", $str, $arr);
7573

7674
return count($arr[0]);
@@ -84,7 +82,7 @@ static public function length($str)
8482
* @internal param bool $type 计算长度类型,0(默认)表示一个中文算一个字符,1表示一个中文算两个字符
8583
* @return int
8684
*/
87-
static public function abs_length($str)
85+
public static function abs_length($str)
8886
{
8987
if (empty($str)){
9088
return 0;
@@ -94,8 +92,7 @@ static public function abs_length($str)
9492
return mb_strwidth($str,'utf-8');
9593
} else if (function_exists('mb_strlen')){
9694
return mb_strlen($str,'utf-8');
97-
}
98-
else {
95+
} else {
9996
preg_match_all("/./u", $str, $ar);
10097
return count($ar[0]);
10198
}
@@ -109,7 +106,7 @@ static public function abs_length($str)
109106
* @param int $end 要进行截取的长度
110107
* @return string
111108
*/
112-
static public function utf8_substr($str,$start=0,$end=null)
109+
public static function utf8_substr($str,$start=0,$end=null)
113110
{
114111
if (empty($str)){
115112
return false;
@@ -151,7 +148,7 @@ static public function utf8_substr($str,$start=0,$end=null)
151148
* @param bool $suffix 是否加尾缀
152149
* @return string
153150
*/
154-
static public function zh_substr($str, $start=0, $length, $charset="utf-8", $suffix=true)
151+
public static function zh_substr($str, $start=0, $length, $charset="utf-8", $suffix=true)
155152
{
156153
if (function_exists("mb_substr"))
157154
{
@@ -181,7 +178,7 @@ static public function zh_substr($str, $start=0, $length, $charset="utf-8", $suf
181178
* @param $str
182179
* @return bool|string
183180
*/
184-
static public function strtolower($str)
181+
public static function strtolower($str)
185182
{
186183
if (is_array($str)) {
187184
return false;
@@ -199,7 +196,7 @@ static public function strtolower($str)
199196
* @param string $encoding
200197
* @return bool|int
201198
*/
202-
static public function strlen($str, $encoding = 'UTF-8')
199+
public static function strlen($str, $encoding = 'UTF-8')
203200
{
204201
if (is_array($str)) {
205202
return false;
@@ -217,7 +214,7 @@ static public function strlen($str, $encoding = 'UTF-8')
217214
* @param $str
218215
* @return bool|string
219216
*/
220-
static public function strtoupper($str)
217+
public static function strtoupper($str)
221218
{
222219
if (is_array($str)) {
223220
return false;
@@ -237,7 +234,7 @@ static public function strtoupper($str)
237234
* @param string $encoding
238235
* @return bool|string
239236
*/
240-
static public function substr($str, $start, $length = false, $encoding = 'utf-8')
237+
public static function substr($str, $start, $length = false, $encoding = 'utf-8')
241238
{
242239
if (is_array($str)) {
243240
return false;
@@ -257,7 +254,7 @@ static public function substr($str, $start, $length = false, $encoding = 'utf-8'
257254
* @param string $encoding
258255
* @return bool|int
259256
*/
260-
static public function strpos($str, $find, $offset = 0, $encoding = 'UTF-8')
257+
public static function strpos($str, $find, $offset = 0, $encoding = 'UTF-8')
261258
{
262259
if (function_exists('mb_strpos')) {
263260
return mb_strpos($str, $find, $offset, $encoding);
@@ -273,7 +270,7 @@ static public function strpos($str, $find, $offset = 0, $encoding = 'UTF-8')
273270
* @param string $encoding
274271
* @return bool|int
275272
*/
276-
static public function strrpos($str, $find, $offset = 0, $encoding = 'utf-8')
273+
public static function strrpos($str, $find, $offset = 0, $encoding = 'utf-8')
277274
{
278275
if (function_exists('mb_strrpos')) {
279276
return mb_strrpos($str, $find, $offset, $encoding);
@@ -286,7 +283,7 @@ static public function strrpos($str, $find, $offset = 0, $encoding = 'utf-8')
286283
* @param $str
287284
* @return string
288285
*/
289-
static public function ucfirst($str)
286+
public static function ucfirst($str)
290287
{
291288
return self::strtoupper(self::substr($str, 0, 1)).self::substr($str, 1);
292289
}
@@ -295,7 +292,7 @@ static public function ucfirst($str)
295292
* @param $str
296293
* @return string
297294
*/
298-
static public function ucwords($str)
295+
public static function ucwords($str)
299296
{
300297
if (function_exists('mb_convert_case')) {
301298
return mb_convert_case($str, MB_CASE_TITLE);
@@ -306,12 +303,12 @@ static public function ucwords($str)
306303

307304
/**
308305
* Translates a string with underscores into camel case (e.g. first_name -> firstName)
309-
* @prototype string static public function toCamelCase(string $str[, bool $capitalise_first_char = false])
306+
* @prototype string public static function toCamelCase(string $str[, bool $capitalise_first_char = false])
310307
* @param $str
311308
* @param bool $upper_case_first_char
312309
* @return mixed
313310
*/
314-
static public function toCamelCase($str, $upper_case_first_char = false)
311+
public static function toCamelCase($str, $upper_case_first_char = false)
315312
{
316313
$str = self::strtolower($str);
317314

@@ -329,11 +326,11 @@ static public function toCamelCase($str, $upper_case_first_char = false)
329326
* @param string $sep
330327
* @return string
331328
*/
332-
static public function toUnderscoreCase($string, $sep='_')
329+
public static function toUnderscoreCase($string, $sep='_')
333330
{
334331
// 'CMSCategories' => 'cms_categories'
335332
// 'RangePrice' => 'range_price'
336333
return self::strtolower(trim(preg_replace('/([A-Z][a-z])/', $sep . '$1', $string), $sep));
337334
}
338335

339-
}
336+
}

0 commit comments

Comments
 (0)