X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FStrings.php;h=3870074e1a7be84cfc3e6b1f4f17ab37fb4ee202;hb=720a43461d67ab229de0aecfc5008f22cc4c1c54;hp=35e7ebe1510c732ccd793e2837297acdbbf666b0;hpb=f10062dfdbacb48910482678d919ad37de57015f;p=friendica.git diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 35e7ebe151..3870074e1a 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -1,6 +1,6 @@ "], ['[', ']'], $string); - } - /** * Use this on "body" or "content" input where angle chars shouldn't be removed, * and allow them to be safely displayed. @@ -283,7 +268,7 @@ class Strings public static function base64UrlDecode($s) { if (is_array($s)) { - Logger::log('base64url_decode: illegal input: ' . print_r(debug_backtrace(), true)); + Logger::notice('base64url_decode: illegal input: ', ['backtrace' => debug_backtrace()]); return $s; } @@ -379,6 +364,7 @@ class Strings /** * Check if the first string starts with the second * + * @see http://maettig.com/code/php/php-performance-benchmarks.php#startswith * @param string $string * @param string $start * @return bool @@ -390,6 +376,21 @@ class Strings return $return; } + /** + * Checks if the first string ends with the second + * + * @see http://maettig.com/code/php/php-performance-benchmarks.php#endswith + * @param string $string + * @param string $end + * @return bool + */ + public static function endsWith(string $string, string $end) + { + $return = substr_compare($string, $end, -strlen($end)) === 0; + + return $return; + } + /** * Returns the regular expression string to match URLs in a given text *