diff --git a/src/helpers.php b/src/helpers.php index bb40fe5..786ea09 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -9,12 +9,28 @@ * * @return Editor */ - function s(string $str, string $encoding = 'UTF-8'): Editor + function s(string $str = null, string $encoding = 'UTF-8'): Editor { + if ($str === null) { + return new Editor(); + } + return Editor::create($str, $encoding); } } +if (! function_exists('sf')) { + /** + * @param string $format + * @param mixed ...$substitutions + * @return \Hipsterjazzbo\Editor\Editor + */ + function sf(string $format, ...$substitutions) + { + return Editor::sprintf($format, ...$substitutions); + } +} + if (! function_exists('mb_sprintf')) { /** * @param string $format @@ -26,6 +42,7 @@ function mb_sprintf(string $format, ...$substitutions): string return Editor::sprintf($format, ...$substitutions)->str(); } } + if (! function_exists('mb_vsprintf')) { /** * Works with all encodings in format and arguments.