forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringHelper.php
More file actions
36 lines (29 loc) · 890 Bytes
/
StringHelper.php
File metadata and controls
36 lines (29 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace ProcessMaker\Helpers;
class StringHelper
{
public static function normalize($string)
{
$string = static::unSnakeSlug($string);
$string = static::unStudlyCamelCase($string);
$string = static::removeExtraWhitespace($string);
$string = mb_convert_case($string, MB_CASE_TITLE);
return $string;
}
public static function friendlyFileName($string)
{
return strtolower(preg_replace('/[^\w\.!@#$^+=-]/', '_', $string));
}
public static function unSnakeSlug($string)
{
return trim(preg_replace('/[_-]/', ' ', $string));
}
public static function unStudlyCamelCase($string)
{
return trim(preg_replace('/([A-Z])/', ' $1', $string));
}
public static function removeExtraWhitespace($string)
{
return trim(preg_replace('/\s{2,}/', ' ', $string));
}
}