| Total Complexity | 4 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | final class StringUtils |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Returns true if $haystack starts with $needle. |
||
| 21 | */ |
||
| 22 | public static function startsWith(string $needle, string $haystack): bool |
||
| 23 | { |
||
| 24 | return str_starts_with($haystack, $needle); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Remove $needle from start of $haystack. |
||
| 29 | */ |
||
| 30 | public static function removeFromStart(string $needle, string $haystack): string |
||
| 31 | { |
||
| 32 | Assert::true(self::startsWith($needle, $haystack)); |
||
| 33 | $length = strlen($needle); |
||
| 34 | |||
| 35 | return substr($haystack, $length); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Returns true if $haystack ends with $needle. |
||
| 40 | */ |
||
| 41 | public static function endsWith(string $needle, string $haystack): bool |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Returns true if line is empty (or contains only white space). |
||
| 50 | */ |
||
| 51 | public static function isEmptyLine(string $line): bool |
||
| 54 | } |
||
| 55 | } |
||
| 56 |