Strings Class
Aurora\Helpers Namespace
Methods
slugify
Sanitize the given string (slugify it)
Parameters
-
string$str— The string to sanitize -
array$replace— Optional, an array of characters to replace -
string$delimiter— Optional, specify a custom delimiter
Return Value
string
Signature
public function slugify(string $str, array $replace = [], string $delimiter = '-'): string
camelToSnake
Convert camelCase to snake_case
Parameters
-
string$val— Original string
Return Value
string
Signature
public function camelToSnake(string $val): string
camelToDash
Convert camelCase to dash-case
Parameters
-
string$val— Original string
Return Value
string
Signature
public function camelToDash(string $val): string
snakeToCamel
Convert snake_case to camelCase
Parameters
-
string$val— Original string
Return Value
string
Signature
public function snakeToCamel(string $val): string
dashToCamel
Convert dash-case to camelCase
Parameters
-
string$val— Original string
Return Value
string
Signature
public function dashToCamel(string $val): string
singularPlural
Get the singular or plural form of a word based on a quantity
Parameters
-
mixed$number— The quantity -
string$singular— Singular form of the word -
string$plural— Plural form of the word
Return Value
string
Signature
public function singularPlural(mixed $number, string $singular, string $plural = ''): string
boolean
Return a string representing a boolean value
Parameters
-
bool$expr— Boolean value or expression -
string$true— Value for TRUE -
string$false— Value for FALSE
Return Value
string
Signature
public function boolean(bool $expr, string $true = 'On', string $false = 'Off'): string
limit
Truncate a string and print it
Parameters
-
string$expr— String to truncate and print -
int$chars— Character count -
bool$reverse— Whether to keep or remove the number of specified characters
Signature
public function limit(string $expr, int $chars = 100, bool $reverse)
startsWith
Check if a string starts with another string
Parameters
-
string$haystack— The string to search in -
string$needle— The substring to search for in the haystack
Return Value
bool
Signature
public function startsWith(string $haystack, string $needle): bool
endsWith
Check if a string ends with another string
Parameters
-
string$haystack— The string to search in -
string$needle— The substring to search for in the haystack
Return Value
bool
Signature
public function endsWith(string $haystack, string $needle): bool