Str
Uses
Properties
$snakeCache array
The cache of snake-cased words.
$camelCache array
The cache of camel-cased words.
$studlyCache array
The cache of studly-cased words.
$uuidFactory callable|null
The callback that should be used to generate UUIDs.
$randomStringFactory callable|null
The callback that should be used to generate random strings.
Methods
of ( $string ) : Stringable
Get a new stringable object from the given string.
Parameters
- $string string
after ( $subject , $search ) : string
Return the remainder of a string after the first occurrence of a given value.
Parameters
- $subject string
- $search string
afterLast ( $subject , $search ) : string
Return the remainder of a string after the last occurrence of a given value.
Parameters
- $subject string
- $search string
ascii ( $value , $language ) : string
Transliterate a UTF-8 value to ASCII.
Parameters
- $value string
- $language string
transliterate ( $string , $unknown , $strict ) : string
Transliterate a string to its closest ASCII representation.
Parameters
- $string string
- $unknown string|null
- $strict bool|null
before ( $subject , $search ) : string
Get the portion of a string before the first occurrence of a given value.
Parameters
- $subject string
- $search string
beforeLast ( $subject , $search ) : string
Get the portion of a string before the last occurrence of a given value.
Parameters
- $subject string
- $search string
between ( $subject , $from , $to ) : string
Get the portion of a string between two given values.
Parameters
- $subject string
- $from string
- $to string
betweenFirst ( $subject , $from , $to ) : string
Get the smallest possible portion of a string between two given values.
Parameters
- $subject string
- $from string
- $to string
camel ( $value ) : string
Convert a value to camel case.
Parameters
- $value string
charAt ( $subject , $index ) : string|false
Get the character at the specified index.
Parameters
- $subject string
- $index int
contains ( $haystack , $needles , $ignoreCase ) : bool
Determine if a given string contains a given substring.
Parameters
- $haystack string
-
$needles
string|iterable
- $ignoreCase bool
containsAll ( $haystack , $needles , $ignoreCase ) : bool
Determine if a given string contains all array values.
Parameters
- $haystack string
-
$needles
iterable
- $ignoreCase bool
endsWith ( $haystack , $needles ) : bool
Determine if a given string ends with a given substring.
Parameters
- $haystack string
-
$needles
string|iterable
excerpt ( $text , $phrase , $options ) : string|null
Extracts an excerpt from text that matches the first instance of a phrase.
Parameters
- $text string
- $phrase string
- $options array
finish ( $value , $cap ) : string
Cap a string with a single instance of a given value.
Parameters
- $value string
- $cap string
wrap ( $value , $before , $after ) : string
Wrap the string with the given strings.
Parameters
- $value string
- $before string
- $after string|null
is ( $pattern , $value ) : bool
Determine if a given string matches a given pattern.
Parameters
-
$pattern
string|iterable
- $value string
isAscii ( $value ) : bool
Determine if a given string is 7 bit ASCII.
Parameters
- $value string
isJson ( $value ) : bool
Determine if a given value is valid JSON.
Parameters
- $value mixed
isUrl ( $value , array $protocols ) : bool
Determine if a given value is a valid URL.
Parameters
- $value mixed
- $protocols array
isUuid ( $value ) : bool
Determine if a given value is a valid UUID.
Parameters
- $value mixed
isUlid ( $value ) : bool
Determine if a given value is a valid ULID.
Parameters
- $value mixed
kebab ( $value ) : string
Convert a string to kebab case.
Parameters
- $value string
length ( $value , $encoding ) : int
Return the length of the given string.
Parameters
- $value string
- $encoding string|null
limit ( $value , $limit , $end ) : string
Limit the number of characters in a string.
Parameters
- $value string
- $limit int
- $end string
lower ( $value ) : string
Convert the given string to lower-case.
Parameters
- $value string
words ( $value , $words , $end ) : string
Limit the number of words in a string.
Parameters
- $value string
- $words int
- $end string
markdown ( $string , array $options ) : string
Converts GitHub flavored Markdown into HTML.
Parameters
- $string string
- $options array
inlineMarkdown ( $string , array $options ) : string
Converts inline Markdown into HTML.
Parameters
- $string string
- $options array
mask ( $string , $character , $index , $length , $encoding ) : string
Masks a portion of a string with a repeated character.
Parameters
- $string string
- $character string
- $index int
- $length int|null
- $encoding string
match ( $pattern , $subject ) : string
Get the string matching the given pattern.
Parameters
- $pattern string
- $subject string
isMatch ( $pattern , $value ) : bool
Determine if a given string matches a given pattern.
Parameters
-
$pattern
string|iterable
- $value string
matchAll ( $pattern , $subject ) : Illuminate\...\Collection
Get the string matching the given pattern.
Parameters
- $pattern string
- $subject string
padBoth ( $value , $length , $pad ) : string
Pad both sides of a string with another.
Parameters
- $value string
- $length int
- $pad string
padLeft ( $value , $length , $pad ) : string
Pad the left side of a string with another.
Parameters
- $value string
- $length int
- $pad string
padRight ( $value , $length , $pad ) : string
Pad the right side of a string with another.
Parameters
- $value string
- $length int
- $pad string
parseCallback
(
$callback
,
$default
)
:
array|null>
Parse a Class[@]method style callback into class and method.
Parameters
- $callback string
- $default string|null
plural ( $value , $count ) : string
Get the plural form of an English word.
Parameters
- $value string
- $count int|array|Countable
pluralStudly ( $value , $count ) : string
Pluralize the last word of an English, studly caps case string.
Parameters
- $value string
- $count int|array|Countable
password ( $length , $letters , $numbers , $symbols , $spaces ) : string
Generate a random, secure password.
Parameters
- $length int
- $letters bool
- $numbers bool
- $symbols bool
- $spaces bool
random ( $length ) : string
Generate a more truly "random" alpha-numeric string.
Parameters
- $length int
createRandomStringsUsing ( callable $factory ) : void
Set the callable that will be used to generate random strings.
Parameters
- $factory callable|null
createRandomStringsUsingSequence ( array $sequence , $whenMissing ) : void
Set the sequence that will be used to generate random strings.
Parameters
- $sequence array
- $whenMissing callable|null
createRandomStringsNormally ( ) : void
Indicate that random strings should be created normally and not using a custom factory.
repeat ( string $string , int $times ) : string
Repeat the given string.
Parameters
- $string string
- $times int
replaceArray ( $search , $replace , $subject ) : string
Replace a given value in the string sequentially with an array.
Parameters
- $search string
-
$replace
iterable
- $subject string
replace ( $search , $replace , $subject , $caseSensitive ) : string|string[]
Replace the given value in the given string.
Parameters
-
$search
string|iterable
-
$replace
string|iterable
-
$subject
string|iterable
- $caseSensitive bool
replaceFirst ( $search , $replace , $subject ) : string
Replace the first occurrence of a given value in the string.
Parameters
- $search string
- $replace string
- $subject string
replaceLast ( $search , $replace , $subject ) : string
Replace the last occurrence of a given value in the string.
Parameters
- $search string
- $replace string
- $subject string
remove ( $search , $subject , $caseSensitive ) : string
Remove any occurrence of the given string in the subject.
Parameters
-
$search
string|iterable
-
$subject
string|iterable
- $caseSensitive bool
reverse ( string $value ) : string
Reverse the given string.
Parameters
- $value string
start ( $value , $prefix ) : string
Begin a string with a single instance of a given value.
Parameters
- $value string
- $prefix string
upper ( $value ) : string
Convert the given string to upper-case.
Parameters
- $value string
title ( $value ) : string
Convert the given string to title case.
Parameters
- $value string
headline ( $value ) : string
Convert the given string to title case for each word.
Parameters
- $value string
singular ( $value ) : string
Get the singular form of an English word.
Parameters
- $value string
slug ( $title , $separator , $language , $dictionary ) : string
Generate a URL friendly "slug" from a given string.
Parameters
- $title string
- $separator string
- $language string|null
-
$dictionary
array
snake ( $value , $delimiter ) : string
Convert a string to snake case.
Parameters
- $value string
- $delimiter string
squish ( $value ) : string
Remove all "extra" blank space from the given string.
Parameters
- $value string
startsWith ( $haystack , $needles ) : bool
Determine if a given string starts with a given substring.
Parameters
- $haystack string
-
$needles
string|iterable
studly ( $value ) : string
Convert a value to studly caps case.
Parameters
- $value string
substr ( $string , $start , $length , $encoding ) : string
Returns the portion of the string specified by the start and length parameters.
Parameters
- $string string
- $start int
- $length int|null
- $encoding string
substrCount ( $haystack , $needle , $offset , $length ) : int
Returns the number of substring occurrences.
Parameters
- $haystack string
- $needle string
- $offset int
- $length int|null
substrReplace ( $string , $replace , $offset , $length ) : string|string[]
Replace text within a portion of a string.
Parameters
- $string string|string[]
- $replace string|string[]
- $offset int|int[]
- $length int|int[]|null
swap ( array $map , $subject ) : string
Swap multiple keywords in a string with other keywords.
Parameters
- $map array
- $subject string
lcfirst ( $string ) : string
Make a string's first character lowercase.
Parameters
- $string string
ucfirst ( $string ) : string
Make a string's first character uppercase.
Parameters
- $string string
ucsplit ( $string ) : string[]
Split a string into pieces by uppercase characters.
Parameters
- $string string
wordCount ( $string , $characters ) : int
Get the number of words a string contains.
Parameters
- $string string
- $characters string|null
wordWrap ( $string , $characters , $break , $cutLongWords ) : string
Wrap a string to a given number of characters.
Parameters
- $string string
- $characters int
- $break string
- $cutLongWords bool
uuid ( ) : Ramsey\...\UuidInterface
Generate a UUID (version 4).
orderedUuid ( ) : Ramsey\...\UuidInterface
Generate a time-ordered UUID (version 4).
createUuidsUsing ( callable $factory ) : void
Set the callable that will be used to generate UUIDs.
Parameters
- $factory callable|null
createUuidsUsingSequence ( array $sequence , $whenMissing ) : void
Set the sequence that will be used to generate UUIDs.
Parameters
- $sequence array
- $whenMissing callable|null
freezeUuids ( Closure $callback ) : Ramsey\...\UuidInterface
Always return the same UUID when generating new UUIDs.
Parameters
- $callback Closure |null
createUuidsNormally ( ) : void
Indicate that UUIDs should be created normally and not using a custom factory.
ulid ( $time ) : Symfony\...\Ulid
Generate a ULID.
Parameters
- $time DateTimeInterface |null
flushCache ( ) : void
Remove all strings from the casing caches.