1 | <?php |
||
10 | class StringUtils |
||
11 | { |
||
12 | /** |
||
13 | * @param string $filename |
||
14 | * @param bool $lowercase |
||
15 | * |
||
16 | * @throws \InvalidArgumentException |
||
17 | * |
||
18 | * @return string |
||
19 | */ |
||
20 | 9 | public static function getFileExtension($filename, $lowercase = true) |
|
29 | |||
30 | /** |
||
31 | * Determine if a string ends with a particular sequence. |
||
32 | * |
||
33 | * @param string $haystack |
||
34 | * @param string $needle |
||
35 | * |
||
36 | * @throws \InvalidArgumentException |
||
37 | * |
||
38 | * @return bool |
||
39 | */ |
||
40 | 12 | public static function stringEndsWith($haystack, $needle) |
|
48 | |||
49 | /** |
||
50 | * Determine if a string starts with a particular sequence. |
||
51 | * |
||
52 | * @param string $haystack |
||
53 | * @param string $needle |
||
54 | * |
||
55 | * @throws \InvalidArgumentException |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | 12 | public static function stringStartsWith($haystack, $needle) |
|
67 | |||
68 | /** |
||
69 | * Remove the prefix from the provided string. |
||
70 | * |
||
71 | * @param string $haystack |
||
72 | * @param string $prefix |
||
73 | * |
||
74 | * @throws \InvalidArgumentException |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | 12 | public static function removePrefix($haystack, $prefix) |
|
90 | |||
91 | /** |
||
92 | * Convert strings with underscores into CamelCase (for getters and setters). |
||
93 | * |
||
94 | * @param string $string The string to convert |
||
95 | * @param bool $firstCharCaps camelCase or CamelCase |
||
96 | * |
||
97 | * @throws \Ddeboer\Transcoder\Exception\UnsupportedEncodingException |
||
98 | * @throws \Ddeboer\Transcoder\Exception\ExtensionMissingException |
||
99 | * @throws \InvalidArgumentException |
||
100 | * |
||
101 | * @return string The converted string |
||
102 | */ |
||
103 | 12 | public static function toCamelCase($string, $firstCharCaps = true) |
|
118 | |||
119 | /** |
||
120 | * Internal function for toUnderscore. |
||
121 | * |
||
122 | * @param string $word |
||
123 | * |
||
124 | * @throws \InvalidArgumentException |
||
125 | * |
||
126 | * @return string |
||
127 | */ |
||
128 | 17 | private static function wordToUnderscored($word) |
|
145 | |||
146 | /** |
||
147 | * Converts a string to underscore version. |
||
148 | * Also tries to filter out higher UTF-8 chars. |
||
149 | * |
||
150 | * @param string $string |
||
151 | * |
||
152 | * @throws \Ddeboer\Transcoder\Exception\UnsupportedEncodingException |
||
153 | * @throws \Ddeboer\Transcoder\Exception\ExtensionMissingException |
||
154 | * @throws \InvalidArgumentException |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | 22 | public static function toUnderscore($string) |
|
170 | } |
||
171 |