PluginProbe
SQLite Database Integration / 2.2.9
SQLite Database Integration v2.2.9
3.0.1 trunk 2.1.13 2.1.14 2.1.15 2.1.16 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.2.2 2.2.20 2.2.21 2.2.22 2.2.23 2.2.3 2.2.4 All 31 releases
sqlite-database-integration / php-polyfills.php

php-polyfills.php in SQLite Database Integration 2.2.9, at php-polyfills.php

55 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Polyfills for php 7 & 8 functions
4 *
5 * @package wp-sqlite-integration
6 */
7
8 if ( ! function_exists( 'str_starts_with' ) ) {
9 /**
10 * Check if a string starts with a specific substring.
11 *
12 * @param string $haystack The string to search in.
13 * @param string $needle The string to search for.
14 *
15 * @see https://www.php.net/manual/en/function.str-starts-with
16 *
17 * @return bool
18 */
19 function str_starts_with( string $haystack, string $needle ) {
20 return empty( $needle ) || 0 === strpos( $haystack, $needle );
21 }
22 }
23
24 if ( ! function_exists( 'str_contains' ) ) {
25 /**
26 * Check if a string contains a specific substring.
27 *
28 * @param string $haystack The string to search in.
29 * @param string $needle The string to search for.
30 *
31 * @see https://www.php.net/manual/en/function.str-contains
32 *
33 * @return bool
34 */
35 function str_contains( string $haystack, string $needle ) {
36 return empty( $needle ) || false !== strpos( $haystack, $needle );
37 }
38 }
39
40 if ( ! function_exists( 'str_ends_with' ) ) {
41 /**
42 * Check if a string ends with a specific substring.
43 *
44 * @param string $haystack The string to search in.
45 * @param string $needle The string to search for.
46 *
47 * @see https://www.php.net/manual/en/function.str-ends-with
48 *
49 * @return bool
50 */
51 function str_ends_with( string $haystack, string $needle ) {
52 return empty( $needle ) || substr( $haystack, -strlen( $needle ) === $needle );
53 }
54 }
55