Skip to content

Commit e1e7798

Browse files
committed
up: add new string func for split string to words
1 parent 3c0bfc6 commit e1e7798

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Str/Traits/StringCaseHelperTrait.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,19 @@ public static function toSnakeCase(string $str, string $sep = '_'): string
265265
return self::lower(trim(preg_replace('/([A-Z][a-z])/', $sep . '$1', $str), $sep));
266266
}
267267

268+
/**
269+
* @param string $str
270+
*
271+
* @return string
272+
*/
273+
public static function toLowerWords(string $str): string
274+
{
275+
$str = str_replace(['-', '_'], ' ', $str);
276+
$str = preg_replace('/([A-Z][a-z])/', ' $1', $str);
277+
278+
return strtolower($str);
279+
}
280+
268281
/**
269282
* 驼峰式 <=> 下划线式
270283
*

src/Str/Traits/StringConvertTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ public static function toNoEmptyArray(string $str, string $sep = ',', int $limit
254254
public static function splitNoEmptyArray(string $str, string $sep = ',', int $limit = 0): array
255255
{
256256
return self::toNoEmptyArray($str, $sep, $limit);
257-
;
258257
}
259258

260259
/**

0 commit comments

Comments
 (0)