diff --git a/src/Util/Common.php b/src/Util/Common.php index 6c52b86375..76ffba55e0 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -237,16 +237,16 @@ abstract class Common } /** - * If $secure is true, only allow https URLs to pass + * If $ensure_secure is true, only allow https URLs to pass */ - public function isValidHttpUrl(string $url, bool $ensure_secure = false) + public static function isValidHttpUrl(string $url, bool $ensure_secure = false) { if (empty($url)) { return false; } // (if false, we use '?' in 'https?' to say the 's' is optional) - $regex = $secure ? '/^https$/' : '/^https?$/'; + $regex = $ensure_secure ? '/^https$/' : '/^https?$/'; return filter_var($url, FILTER_VALIDATE_URL) && preg_match($regex, parse_url($url, PHP_URL_SCHEME)); } diff --git a/src/Util/Formatting.php b/src/Util/Formatting.php index b001009733..4a1cf2f3e2 100644 --- a/src/Util/Formatting.php +++ b/src/Util/Formatting.php @@ -133,6 +133,16 @@ abstract class Formatting }); } + public static function removePrefix(string $haystack, string $needle) + { + return substr($haystack, strlen($needle)); + } + + public static function removeSuffix(string $haystack, string $needle) + { + return substr($haystack, -strlen($needle)); + } + public static function camelCaseToSnakeCase(string $str): string { return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $str));