PluginProbe
Independent Analytics – WordPress Analytics Plugin / 1.24.0
Independent Analytics – WordPress Analytics Plugin v1.24.0
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 All 120 releases
independent-analytics / IAWP / Utils / String_Util.php
String_Util.php
29 lines 827 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IAWP_SCOPED\IAWP\Utils;
4
5 class String_Util
6 {
7 /** These functions are copied verbatim from the WordPress polyfills added in 5.9.
8 * They allow us to use these PHP 8 functions with PHP 7 and WP 5.5 */
9 public static function str_contains($haystack, $needle)
10 {
11 return '' === $needle || \false !== \strpos($haystack, $needle);
12 }
13 public static function str_starts_with($haystack, $needle)
14 {
15 if ('' === $needle) {
16 return \true;
17 }
18 return 0 === \strpos($haystack, $needle);
19 }
20 public static function str_ends_with($haystack, $needle)
21 {
22 if ('' === $haystack && '' !== $needle) {
23 return \false;
24 }
25 $len = \strlen($needle);
26 return 0 === \substr_compare($haystack, $needle, -$len, $len);
27 }
28 }
29