diff options
Diffstat (limited to 'lib/php8backports.php')
-rw-r--r-- | lib/php8backports.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/php8backports.php b/lib/php8backports.php new file mode 100644 index 00000000..aa68b77a --- /dev/null +++ b/lib/php8backports.php @@ -0,0 +1,32 @@ +<?php +/** + * This file is part of RSS-Bridge, a PHP project capable of generating RSS and + * Atom feeds for websites that don't have one. + * + * For the full license information, please view the UNLICENSE file distributed + * with this source code. + * + * @package Core + * @license http://unlicense.org/ UNLICENSE + * @link https://github.com/rss-bridge/rss-bridge + */ + +// based on https://github.com/laravel/framework/blob/8.x/src/Illuminate/Support/Str.php + +if (!function_exists('str_starts_with')) { + function str_starts_with($haystack, $needle) { + return (string)$needle !== '' && strncmp($haystack, $needle, strlen($needle)) === 0; + } +} + +if (!function_exists('str_ends_with')) { + function str_ends_with($haystack, $needle) { + return $needle !== '' && substr($haystack, -strlen($needle)) === (string)$needle; + } +} + +if (!function_exists('str_contains')) { + function str_contains($haystack, $needle) { + return $needle !== '' && mb_strpos($haystack, $needle) !== false; + } +} |