Skip to content

Commit

Permalink
Add sf() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
hipsterjazzbo committed Apr 22, 2020
1 parent 42ac0e4 commit b12e1da
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit b12e1da

Please sign in to comment.