-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* Polyfills for php 7 & 8 functions | ||
* | ||
* @package wp-sqlite-integration | ||
*/ | ||
|
||
if ( ! function_exists( 'str_starts_with' ) ) { | ||
/** | ||
* Check if a string starts with a specific substring. | ||
* | ||
* @param string $haystack The string to search in. | ||
* @param string $needle The string to search for. | ||
* | ||
* @see https://www.php.net/manual/en/function.str-starts-with | ||
* | ||
* @return bool | ||
*/ | ||
function str_starts_with( string $haystack, string $needle ) { | ||
return empty( $needle ) || 0 === strpos( $haystack, $needle ); | ||
} | ||
} | ||
|
||
if ( ! function_exists( 'str_contains' ) ) { | ||
/** | ||
* Check if a string contains a specific substring. | ||
* | ||
* @param string $haystack The string to search in. | ||
* @param string $needle The string to search for. | ||
* | ||
* @see https://www.php.net/manual/en/function.str-contains | ||
* | ||
* @return bool | ||
*/ | ||
function str_contains( string $haystack, string $needle ) { | ||
return empty( $needle ) || false !== strpos( $haystack, $needle ); | ||
} | ||
} | ||
|
||
if ( ! function_exists( 'str_ends_with' ) ) { | ||
/** | ||
* Check if a string ends with a specific substring. | ||
* | ||
* @param string $haystack The string to search in. | ||
* @param string $needle The string to search for. | ||
* | ||
* @see https://www.php.net/manual/en/function.str-ends-with | ||
* | ||
* @return bool | ||
*/ | ||
function str_ends_with( string $haystack, string $needle ) { | ||
return empty( $needle ) || substr( $haystack, -strlen( $needle ) === $needle ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters