2022-12-07 11:43:09 -07:00

30 lines
783 B
PHP

<?php
// phpcs:ignore
/**
|--------------------------------------------------------------------------
| Global String Functions
|--------------------------------------------------------------------------
|
| This is a home for functions that don't belong to any one class and
| that should be available anywhere in the application.
|
*/
if (! function_exists('snake2Title')) {
/**
* Convert a snake case string to a title with spaces
* and every word capitalized.
*
* @param string $snakeSlug A snake case string, commonly a slug
*
* @since 1.0.0
*
* @return string
*/
function snake2Title(string $snakeSlug): string
{
$output = preg_replace('/\_/', ' ', $snakeSlug);
return ucwords($output);
}
}