From 46b4a4073a5a27288602eece81e970717dc3fa15 Mon Sep 17 00:00:00 2001 From: Yahya Erturan Date: Thu, 5 Mar 2020 15:32:15 +0300 Subject: [PATCH] `str_slug_force` added. `str_snake_case_safe` renamed to `str_snake_case_force` --- Helper.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Helper.php b/Helper.php index 614fb4c..502cf82 100644 --- a/Helper.php +++ b/Helper.php @@ -15,7 +15,8 @@ * str_camel_case($value) * str_studly_case($value) * str_slug($title, $separator = '-') - * str_snake_case_safe($title, $separator = '_') + * str_snake_case_force($title, $separator = '_') + * str_slug_force($title, $separator = '-') * str_json($str = '/', $returnDecoded = true, $asArray = false) */ @@ -238,7 +239,7 @@ function str_slug($title, $separator = '-') // ------------------------------------------------------------------------ -if ( ! function_exists('str_snake_case_safe')) { +if ( ! function_exists('str_snake_case_force')) { /** * @inheritDoc str_slug * @@ -246,7 +247,23 @@ function str_slug($title, $separator = '-') * @param string $separator * @return string */ - function str_snake_case_safe($title, $separator = '_') + function str_snake_case_force($title, $separator = '_') + { + return str_slug(str_snake_case($title), $separator); + } +} + +// ------------------------------------------------------------------------ + +if ( ! function_exists('str_slug_force')) { + /** + * @inheritDoc str_slug + * + * @param string $title + * @param string $separator + * @return string + */ + function str_slug_force($title, $separator = '-') { return str_slug(str_snake_case($title), $separator); }