Str
class Str
Properties
static protected array | $snakeCache | The cache of snake-cased words. | |
static protected array | $camelCache | The cache of camel-cased words. | |
static protected array | $studlyCache | The cache of studly-cased words. |
Methods
Transliterate a UTF-8 value to ASCII.
Convert a value to camel case.
Determine if a given string contains a given substring.
Determine if a given string ends with a given substring.
Cap a string with a single instance of a given value.
Determine if a given string matches a given pattern.
Return the length of the given string.
Limit the number of characters in a string.
Convert the given string to lower-case.
Limit the number of words in a string.
Parse a "Class@method" style callback into class and method.
Generate a more truly "random" alpha-numeric string.
Generate a "random" alpha-numeric string.
Compares two strings using a constant-time algorithm.
Replace the first occurrence of a given value in the string.
Replace the last occurrence of a given value in the string.
Convert the given string to upper-case.
Convert the given string to title case.
Generate a URL friendly "slug" from a given string.
Convert a string to snake case.
Determine if a given string starts with a given substring.
Convert a value to studly caps case.
Returns the portion of string specified by the start and length parameters.
Make a string's first character uppercase.
Returns the replacements for the ascii method.
Details
at line 39
static string
ascii(string $value)
Transliterate a UTF-8 value to ASCII.
at line 54
static string
camel(string $value)
Convert a value to camel case.
at line 70
static bool
contains(string $haystack, string|array $needles)
Determine if a given string contains a given substring.
at line 88
static bool
endsWith(string $haystack, string|array $needles)
Determine if a given string ends with a given substring.
at line 107
static string
finish(string $value, string $cap)
Cap a string with a single instance of a given value.
at line 121
static bool
is(string $pattern, string $value)
Determine if a given string matches a given pattern.
at line 143
static int
length(string $value)
Return the length of the given string.
at line 156
static string
limit(string $value, int $limit = 100, string $end = '...')
Limit the number of characters in a string.
at line 171
static string
lower(string $value)
Convert the given string to lower-case.
at line 184
static string
words(string $value, int $words = 100, string $end = '...')
Limit the number of words in a string.
at line 202
static array
parseCallback(string $callback, string $default = "")
Parse a "Class@method" style callback into class and method.
at line 214
static string
random(int $length = 16)
Generate a more truly "random" alpha-numeric string.
at line 238
static string
randomBytes(int $length = 16)
deprecated
deprecated
Generate a more truly "random" bytes.
at line 251
static string
quickRandom(int $length = 16)
Generate a "random" alpha-numeric string.
Should not be considered sufficient for cryptography, etc.
at line 271
static bool
equals(string $knownString, string $userInput)
deprecated
deprecated
Compares two strings using a constant-time algorithm.
Note: This method will leak length information.
Note: Adapted from Symfony\Component\Security\Core\Util\StringUtils.
at line 284
static string
replaceFirst(string $search, string $replace, string $subject)
Replace the first occurrence of a given value in the string.
at line 303
static string
replaceLast(string $search, string $replace, string $subject)
Replace the last occurrence of a given value in the string.
at line 320
static string
upper(string $value)
Convert the given string to upper-case.
at line 331
static string
title(string $value)
Convert the given string to title case.
at line 343
static string
slug(string $title, string $separator = '-')
Generate a URL friendly "slug" from a given string.
at line 368
static string
snake(string $value, string $delimiter = '_')
Convert a string to snake case.
at line 392
static bool
startsWith(string $haystack, string|array $needles)
Determine if a given string starts with a given substring.
at line 409
static string
studly(string $value)
Convert a value to studly caps case.
at line 430
static string
substr(string $string, int $start, int $length = null)
Returns the portion of string specified by the start and length parameters.
at line 441
static string
ucfirst(string $string)
Make a string's first character uppercase.
at line 455
static protected array
charsArray()
Returns the replacements for the ascii method.
Note: Adapted from Stringy\Stringy.