| 1 | <?php |
||
| 9 | class StringUtils |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Checks if a string starts with another string. |
||
| 13 | * |
||
| 14 | * @param string $haystack The string to search in. |
||
| 15 | * @param string $needle The string to search. |
||
| 16 | * @return bool |
||
| 17 | */ |
||
| 18 | public static function startsWith(string $haystack, string $needle): bool |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Checks if a string ends with another string. |
||
| 25 | * |
||
| 26 | * @param string $haystack The string to search in. |
||
| 27 | * @param string $needle The string to search. |
||
| 28 | * @return bool |
||
| 29 | */ |
||
| 30 | public static function endsWith(string $haystack, string $needle): bool |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Get the first character of a string. |
||
| 37 | * |
||
| 38 | * @param string $str The string to get the first character of. |
||
| 39 | * @return string|false The first character or false if not found. |
||
| 40 | */ |
||
| 41 | public static function getFirstChar($str) |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Get the last character of a string. |
||
| 53 | * |
||
| 54 | * @param string false The string to get the last character of. |
||
| 55 | * @return string|null The last character or false if not found. |
||
| 56 | */ |
||
| 57 | public static function getLastChar($str) |
||
| 66 | } |
||
| 67 |