1 | <?php |
||
7 | final class StringHelper extends HelperAbstract |
||
8 | { |
||
9 | 2 | public static function isEmpty(string $value): bool |
|
13 | |||
14 | /** |
||
15 | * Returns true if this string starts with the given needle. |
||
16 | * |
||
17 | * @param string $needle |
||
18 | * @param string $haystack |
||
19 | * |
||
20 | * @return bool |
||
21 | */ |
||
22 | 5 | public static function has(string $needle, string $haystack): bool |
|
26 | |||
27 | /** |
||
28 | * Returns true if this string starts with the given needle. |
||
29 | * |
||
30 | * @param string $needle |
||
31 | * @param string $haystack |
||
32 | * |
||
33 | * @return bool |
||
34 | */ |
||
35 | 26 | public static function hasBeginning(string $needle, string $haystack): bool |
|
39 | |||
40 | /** |
||
41 | * Returns true if this string ends with the given needle. |
||
42 | * |
||
43 | * @param string $needle |
||
44 | * @param string $haystack |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | 5 | public static function hasEnding(string $needle, string $haystack): bool |
|
52 | |||
53 | 1 | public static function toCamel(string $string, array $wordSeparators = ['-', '_', ' ']): string |
|
57 | |||
58 | 3 | public static function toSnake(string $string, string $delimiter = '_', array $wordSeparators = ['-', '_', ' ']): string |
|
66 | |||
67 | 5 | public static function toStudly(string $string, array $wordSeparators = ['-', '_', ' ']): string |
|
71 | |||
72 | 2 | public static function isJson(string $string): bool |
|
78 | |||
79 | 6 | public static function remove(string $search, string $haystack): string |
|
83 | |||
84 | 6 | public static function removeFromBeginning(string $search, string $haystack): string |
|
88 | |||
89 | 6 | public static function removeFromEnd(string $search, string $haystack): string |
|
93 | |||
94 | 12 | public static function replace(string $search, string $replacement, string $haystack): string |
|
98 | |||
99 | 24 | public static function replaceFromBeginning(string $search, string $replacement, string $haystack): string |
|
109 | |||
110 | 12 | public static function replaceFromEnd(string $search, string $replacement, string $haystack): string |
|
114 | |||
115 | /** |
||
116 | * Given a string, it returns an SEO friendly slug. |
||
117 | * IE: |
||
118 | * echo slug('`~#this_is_%%a!{(title)}[]_of<>_p@o&$st*;,.\/-~!'); // this-is-a-title-of-post |
||
119 | * |
||
120 | * @param string $string |
||
121 | * @param bool $resultWithDashes set this to false if you want output with spaces as a separator |
||
122 | * @param bool $inputIsEnglishOnly set this to false if your input contains non english words |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | 4 | public static function toSlug(string $string, bool $resultWithDashes = true, bool $inputIsEnglishOnly = true): string |
|
148 | } |
||
149 |