BladeOne.php
2 years ago
CSV.php
9 months ago
Calculations.php
2 years ago
Currency.php
8 months ago
Device.php
1 year ago
Device_Cache.php
2 years ago
Dir.php
5 months ago
Format.php
5 months ago
Link_Validator.php
6 months ago
Number_Formatter.php
5 months ago
Obj.php
6 months ago
Request.php
11 months ago
Salt.php
1 year ago
Security.php
1 year ago
Server.php
2 years ago
Singleton.php
2 years ago
String_Util.php
2 years ago
Timezone.php
5 months ago
URL.php
6 months ago
WP_Async_Request.php
1 year ago
String_Util.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\Utils; |
| 4 | |
| 5 | /** @internal */ |
| 6 | class String_Util |
| 7 | { |
| 8 | /** These functions are copied verbatim from the WordPress polyfills added in 5.9. |
| 9 | * They allow us to use these PHP 8 functions with PHP 7 and WP 5.5 */ |
| 10 | public static function str_contains($haystack, $needle) |
| 11 | { |
| 12 | return '' === $needle || \false !== \strpos($haystack, $needle); |
| 13 | } |
| 14 | public static function str_starts_with($haystack, $needle) |
| 15 | { |
| 16 | if ('' === $needle) { |
| 17 | return \true; |
| 18 | } |
| 19 | return 0 === \strpos($haystack, $needle); |
| 20 | } |
| 21 | public static function str_ends_with($haystack, $needle) |
| 22 | { |
| 23 | if ('' === $haystack && '' !== $needle) { |
| 24 | return \false; |
| 25 | } |
| 26 | $len = \strlen($needle); |
| 27 | return 0 === \substr_compare($haystack, $needle, -$len, $len); |
| 28 | } |
| 29 | } |
| 30 |