Stringable
Implements
Uses
Properties
$value string
The underlying string value.
Methods
__construct ( $value ) : void
Create a new instance of the class.
Parameters
- $value string
after ( $search ) : static
Return the remainder of a string after the first occurrence of a given value.
Parameters
- $search string
afterLast ( $search ) : static
Return the remainder of a string after the last occurrence of a given value.
Parameters
- $search string
append ( $values ) : static
Append the given values to the string.
Parameters
- $values array
ascii ( $language ) : static
Transliterate a UTF-8 value to ASCII.
Parameters
- $language string
basename ( $suffix ) : static
Get the trailing name component of the path.
Parameters
- $suffix string
classBasename ( ) : static
Get the basename of the class path.
before ( $search ) : static
Get the portion of a string before the first occurrence of a given value.
Parameters
- $search string
beforeLast ( $search ) : static
Get the portion of a string before the last occurrence of a given value.
Parameters
- $search string
between ( $from , $to ) : static
Get the portion of a string between two given values.
Parameters
- $from string
- $to string
camel ( ) : static
Convert a value to camel case.
contains ( $needles ) : bool
Determine if a given string contains a given substring.
Parameters
- $needles string|array
containsAll ( array $needles ) : bool
Determine if a given string contains all array values.
Parameters
- $needles array
dirname ( $levels ) : static
Get the parent directory's path.
Parameters
- $levels int
endsWith ( $needles ) : bool
Determine if a given string ends with a given substring.
Parameters
- $needles string|array
exactly ( $value ) : bool
Determine if the string is an exact match with the given value.
Parameters
- $value string
explode ( $delimiter , $limit ) : Collection
Explode the string into an array.
Parameters
- $delimiter string
- $limit int
split ( $pattern , $limit , $flags ) : Collection
Split a string using a regular expression or by length.
Parameters
- $pattern string|int
- $limit int
- $flags int
finish ( $cap ) : static
Cap a string with a single instance of a given value.
Parameters
- $cap string
is ( $pattern ) : bool
Determine if a given string matches a given pattern.
Parameters
- $pattern string|array
isAscii ( ) : bool
Determine if a given string is 7 bit ASCII.
isUuid ( ) : bool
Determine if a given string is a valid UUID.
isEmpty ( ) : bool
Determine if the given string is empty.
isNotEmpty ( ) : bool
Determine if the given string is not empty.
kebab ( ) : static
Convert a string to kebab case.
length ( $encoding ) : int
Return the length of the given string.
Parameters
- $encoding string
limit ( $limit , $end ) : static
Limit the number of characters in a string.
Parameters
- $limit int
- $end string
lower ( ) : static
Convert the given string to lower-case.
markdown ( array $options ) : static
Convert GitHub flavored Markdown into HTML.
Parameters
- $options array
mask ( $character , $index , $length , $encoding ) : static
Masks a portion of a string with a repeated character.
Parameters
- $character string
- $index int
- $length int|null
- $encoding string
match ( $pattern ) : static
Get the string matching the given pattern.
Parameters
- $pattern string
matchAll ( $pattern ) : Collection
Get the string matching the given pattern.
Parameters
- $pattern string
test ( $pattern ) : bool
Determine if the string matches the given pattern.
Parameters
- $pattern string
padBoth ( $length , $pad ) : static
Pad both sides of the string with another.
Parameters
- $length int
- $pad string
padLeft ( $length , $pad ) : static
Pad the left side of the string with another.
Parameters
- $length int
- $pad string
padRight ( $length , $pad ) : static
Pad the right side of the string with another.
Parameters
- $length int
- $pad string
parseCallback ( $default ) : array
Parse a Class@method style callback into class and method.
Parameters
- $default string|null
pipe ( callable $callback ) : static
Call the given callback and return a new string.
Parameters
- $callback callable
plural ( $count ) : static
Get the plural form of an English word.
Parameters
- $count int
pluralStudly ( $count ) : static
Pluralize the last word of an English, studly caps case string.
Parameters
- $count int
prepend ( $values ) : static
Prepend the given values to the string.
Parameters
- $values array
remove ( $search , $caseSensitive ) : static
Remove any occurrence of the given string in the subject.
Parameters
- $search string|string[]
- $caseSensitive bool
reverse ( ) : static
Reverse the string.
repeat ( int $times ) : static
Repeat the string.
Parameters
- $times int
replace ( $search , $replace ) : static
Replace the given value in the given string.
Parameters
- $search string|string[]
- $replace string|string[]
replaceArray ( $search , array $replace ) : static
Replace a given value in the string sequentially with an array.
Parameters
- $search string
- $replace array
replaceFirst ( $search , $replace ) : static
Replace the first occurrence of a given value in the string.
Parameters
- $search string
- $replace string
replaceLast ( $search , $replace ) : static
Replace the last occurrence of a given value in the string.
Parameters
- $search string
- $replace string
replaceMatches ( $pattern , $replace , $limit ) : static
Replace the patterns matching the given regular expression.
Parameters
- $pattern string
- $replace Closure |string
- $limit int
scan ( $format ) : Collection
Parse input from a string to a collection, according to a format.
Parameters
- $format string
start ( $prefix ) : static
Begin a string with a single instance of a given value.
Parameters
- $prefix string
stripTags ( $allowedTags ) : static
Strip HTML and PHP tags from the given string.
Parameters
- $allowedTags string
upper ( ) : static
Convert the given string to upper-case.
title ( ) : static
Convert the given string to title case.
headline ( ) : static
Convert the given string to title case for each word.
singular ( ) : static
Get the singular form of an English word.
slug ( $separator , $language ) : static
Generate a URL friendly "slug" from a given string.
Parameters
- $separator string
- $language string|null
snake ( $delimiter ) : static
Convert a string to snake case.
Parameters
- $delimiter string
startsWith ( $needles ) : bool
Determine if a given string starts with a given substring.
Parameters
- $needles string|array
studly ( ) : static
Convert a value to studly caps case.
substr ( $start , $length ) : static
Returns the portion of the string specified by the start and length parameters.
Parameters
- $start int
- $length int|null
substrCount ( $needle , $offset , $length ) : int
Returns the number of substring occurrences.
Parameters
- $needle string
- $offset int|null
- $length int|null
substrReplace ( $replace , $offset , $length ) : static
Replace text within a portion of a string.
Parameters
- $replace string|array
- $offset array|int
- $length array|int|null
swap ( array $map ) : static
Swap multiple keywords in a string with other keywords.
Parameters
- $map array
trim ( $characters ) : static
Trim the string of the given characters.
Parameters
- $characters string
ltrim ( $characters ) : static
Left trim the string of the given characters.
Parameters
- $characters string
rtrim ( $characters ) : static
Right trim the string of the given characters.
Parameters
- $characters string
ucfirst ( ) : static
Make a string's first character uppercase.
whenContains ( $needles , $callback , $default ) : static
Execute the given callback if the string contains a given substring.
Parameters
- $needles string|array
- $callback callable
- $default callable|null
whenContainsAll ( array $needles , $callback , $default ) : static
Execute the given callback if the string contains all array values.
Parameters
- $needles array
- $callback callable
- $default callable|null
whenEmpty ( $callback , $default ) : static
Execute the given callback if the string is empty.
Parameters
- $callback callable
- $default callable|null
whenNotEmpty ( $callback , $default ) : static
Execute the given callback if the string is not empty.
Parameters
- $callback callable
- $default callable|null
whenEndsWith ( $needles , $callback , $default ) : static
Execute the given callback if the string ends with a given substring.
Parameters
- $needles string|array
- $callback callable
- $default callable|null
whenExactly ( $value , $callback , $default ) : static
Execute the given callback if the string is an exact match with the given value.
Parameters
- $value string
- $callback callable
- $default callable|null
whenIs ( $pattern , $callback , $default ) : static
Execute the given callback if the string matches a given pattern.
Parameters
- $pattern string|array
- $callback callable
- $default callable|null
whenIsAscii ( $callback , $default ) : static
Execute the given callback if the string is 7 bit ASCII.
Parameters
- $callback callable
- $default callable|null
whenIsUuid ( $callback , $default ) : static
Execute the given callback if the string is a valid UUID.
Parameters
- $callback callable
- $default callable|null
whenStartsWith ( $needles , $callback , $default ) : static
Execute the given callback if the string starts with a given substring.
Parameters
- $needles string|array
- $callback callable
- $default callable|null
whenTest ( $pattern , $callback , $default ) : static
Execute the given callback if the string matches the given pattern.
Parameters
- $pattern string
- $callback callable
- $default callable|null
words ( $words , $end ) : static
Limit the number of words in a string.
Parameters
- $words int
- $end string
wordCount ( ) : int
Get the number of words a string contains.
dump ( ) : $this
Dump the string.
dd ( ) : never
Dump the string and end the script.
jsonSerialize ( ) : string
Convert the object to a string when JSON encoded.
__get ( $key ) : mixed
Proxy dynamic properties onto methods.
Parameters
- $key string
__toString ( ) : string
Get the raw string value.