| @@ 27-36 (lines=10) @@ | ||
| 24 | * |
|
| 25 | * @return bool |
|
| 26 | */ |
|
| 27 | public static function startsWith(string $haystack, array $needles = []) : bool |
|
| 28 | { |
|
| 29 | foreach ($needles as $needle) { |
|
| 30 | if (strpos($haystack, (string) $needle) === 0) { |
|
| 31 | return true; |
|
| 32 | } |
|
| 33 | } |
|
| 34 | ||
| 35 | return false; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Determine if a given string ends with a given substring. |
|
| @@ 46-55 (lines=10) @@ | ||
| 43 | * |
|
| 44 | * @return bool |
|
| 45 | */ |
|
| 46 | public static function endsWith(string $haystack, array $needles = []) : bool |
|
| 47 | { |
|
| 48 | foreach ($needles as $needle) { |
|
| 49 | if (strpos(strrev($haystack), (string) $needle) === 0) { |
|
| 50 | return true; |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| 54 | return false; |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Determine if a given string starts and ends with a given substring. |
|