Str
class Str (View source)
Traits
Methods
Dynamically handle calls to the class.
Dynamically handle calls to the class.
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.
Get the plural form of an English word.
Generate a more truly "random" alpha-numeric string.
Generate a more truly "random" bytes.
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.
Get the singular form of an English word.
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.
Details
static
mixed
__callStatic(
string $method,
array $parameters)
Dynamically handle calls to the class.
at line line 69
static
bool
contains(
string $haystack,
string|array $needles)
Determine if a given string contains a given substring.
at line line 87
static
bool
endsWith(
string $haystack,
string|array $needles)
Determine if a given string ends with a given substring.
at line line 105
static
string
finish(
string $value,
string $cap)
Cap a string with a single instance of a given value.
at line line 119
static
bool
is(
string $pattern,
string $value)
Determine if a given string matches a given pattern.
at line line 154
static
string
limit(
string $value,
int $limit = 100,
string $end = '...')
Limit the number of characters in a string.
at line line 182
static
string
words(
string $value,
int $words = 100,
string $end = '...')
Limit the number of words in a string.
at line line 200
static
array
parseCallback(
string $callback,
string $default)
Parse a Class@method style callback into class and method.
at line line 212
static
string
plural(
string $value,
int $count = 2)
Get the plural form of an English word.
at line line 223
static
string
random(
int $length = 16)
Generate a more truly "random" alpha-numeric string.
at line line 259
static
string
quickRandom(
int $length = 16)
Generate a "random" alpha-numeric string.
Should not be considered sufficient for cryptography, etc.
at line line 279
static
bool
equals(
string $knownString,
string $userInput)
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 line 292
static
string
replaceFirst(
string $search,
string $replace,
string $subject)
Replace the first occurrence of a given value in the string.
at line line 311
static
string
replaceLast(
string $search,
string $replace,
string $subject)
Replace the last occurrence of a given value in the string.
at line line 362
static
string
slug(
string $title,
string $separator = '-')
Generate a URL friendly "slug" from a given string.
at line line 387
static
string
snake(
string $value,
string $delimiter = '_')
Convert a string to snake case.
at line line 411
static
bool
startsWith(
string $haystack,
string|array $needles)
Determine if a given string starts with a given substring.
at line line 449
static
string
substr(
string $string,
int $start,
int|null $length = null)
Returns the portion of string specified by the start and length parameters.