Stringable
class Stringable (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
protected string | $value | The underlying string value. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new instance of the class.
Return the remainder of a string after the first occurrence of a given value.
Return the remainder of a string after the last occurrence of a given value.
Append the given values to the string.
Transliterate a UTF-8 value to ASCII.
Get the trailing name component of the path.
Get the portion of a string before the first occurrence of a given value.
Get the portion of a string before the last occurrence of a given value.
Get the portion of a string between two given values.
Convert a value to camel case.
Determine if a given string contains a given substring.
Determine if a given string contains all array values.
Get the parent directory's path.
Determine if a given string ends with a given substring.
Determine if the string is an exact match with the given value.
Explode the string into an array.
Split a string using a regular expression.
Cap a string with a single instance of a given value.
Determine if a given string matches a given pattern.
Determine if a given string is 7 bit ASCII.
Determine if the given string is empty.
Determine if the given string is not empty.
Convert a string to kebab case.
Return the length of the given string.
Limit the number of characters in a string.
Convert the given string to lower-case.
Get the string matching the given pattern.
Get the string matching the given pattern.
Pad both sides of the string with another.
Pad the left side of the string with another.
Pad the right side of the string with another.
Parse a Class@method style callback into class and method.
Get the plural form of an English word.
Pluralize the last word of an English, studly caps case string.
Prepend the given values to the string.
Replace the given value in the given string.
Replace a given value in the string sequentially with an array.
Replace the first occurrence of a given value in the string.
Replace the last occurrence of a given value in the string.
Replace the patterns matching the given regular expression.
Begin a string with a single instance of a given value.
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.
Returns the number of substring occurrences.
Trim the string of the given characters.
Left trim the string of the given characters.
Right trim the string of the given characters.
Make a string's first character uppercase.
Apply the callback's string changes if the given "value" is true.
Execute the given callback if the string is empty.
Limit the number of words in a string.
Dump the string.
Dump the string and end the script.
Proxy dynamic properties onto methods.
Get the raw string value.
Details
static void
macro(string $name, object|callable $macro)
Register a custom macro.
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool
hasMacro(string $name)
Checks if macro is registered.
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
void
__construct(string $value = '')
Create a new instance of the class.
Stringable
after(string $search)
Return the remainder of a string after the first occurrence of a given value.
Stringable
afterLast(string $search)
Return the remainder of a string after the last occurrence of a given value.
Stringable
append(array ...$values)
Append the given values to the string.
Stringable
ascii(string $language = 'en')
Transliterate a UTF-8 value to ASCII.
Stringable
basename(string $suffix = '')
Get the trailing name component of the path.
Stringable
before(string $search)
Get the portion of a string before the first occurrence of a given value.
Stringable
beforeLast(string $search)
Get the portion of a string before the last occurrence of a given value.
Stringable
between(string $from, string $to)
Get the portion of a string between two given values.
Stringable
camel()
Convert a value to camel case.
bool
contains(string|array $needles)
Determine if a given string contains a given substring.
bool
containsAll(array $needles)
Determine if a given string contains all array values.
Stringable
dirname(int $levels = 1)
Get the parent directory's path.
bool
endsWith(string|array $needles)
Determine if a given string ends with a given substring.
bool
exactly(string $value)
Determine if the string is an exact match with the given value.
Collection
explode(string $delimiter, int $limit = PHP_INT_MAX)
Explode the string into an array.
Collection
split(string $pattern, int $limit = -1, int $flags = 0)
Split a string using a regular expression.
Stringable
finish(string $cap)
Cap a string with a single instance of a given value.
bool
is(string|array $pattern)
Determine if a given string matches a given pattern.
bool
isAscii()
Determine if a given string is 7 bit ASCII.
bool
isEmpty()
Determine if the given string is empty.
bool
isNotEmpty()
Determine if the given string is not empty.
Stringable
kebab()
Convert a string to kebab case.
int
length(string $encoding = null)
Return the length of the given string.
Stringable
limit(int $limit = 100, string $end = '...')
Limit the number of characters in a string.
Stringable
lower()
Convert the given string to lower-case.
Stringable|null
match(string $pattern)
Get the string matching the given pattern.
Collection
matchAll(string $pattern)
Get the string matching the given pattern.
Stringable
padBoth(int $length, string $pad = ' ')
Pad both sides of the string with another.
Stringable
padLeft(int $length, string $pad = ' ')
Pad the left side of the string with another.
Stringable
padRight(int $length, string $pad = ' ')
Pad the right side of the string with another.
array
parseCallback(string|null $default = null)
Parse a Class@method style callback into class and method.
Stringable
plural(int $count = 2)
Get the plural form of an English word.
Stringable
pluralStudly(int $count = 2)
Pluralize the last word of an English, studly caps case string.
Stringable
prepend(array ...$values)
Prepend the given values to the string.
Stringable
replace(string|string[] $search, string|string[] $replace)
Replace the given value in the given string.
Stringable
replaceArray(string $search, array $replace)
Replace a given value in the string sequentially with an array.
Stringable
replaceFirst(string $search, string $replace)
Replace the first occurrence of a given value in the string.
Stringable
replaceLast(string $search, string $replace)
Replace the last occurrence of a given value in the string.
Stringable
replaceMatches(string $pattern, Closure|string $replace, int $limit = -1)
Replace the patterns matching the given regular expression.
Stringable
start(string $prefix)
Begin a string with a single instance of a given value.
Stringable
upper()
Convert the given string to upper-case.
Stringable
title()
Convert the given string to title case.
Stringable
singular()
Get the singular form of an English word.
Stringable
slug(string $separator = '-', string|null $language = 'en')
Generate a URL friendly "slug" from a given string.
Stringable
snake(string $delimiter = '_')
Convert a string to snake case.
bool
startsWith(string|array $needles)
Determine if a given string starts with a given substring.
Stringable
studly()
Convert a value to studly caps case.
Stringable
substr(int $start, int|null $length = null)
Returns the portion of string specified by the start and length parameters.
int
substrCount(string $needle, int|null $offset = null, int|null $length = null)
Returns the number of substring occurrences.
Stringable
trim(string $characters = null)
Trim the string of the given characters.
Stringable
ltrim(string $characters = null)
Left trim the string of the given characters.
Stringable
rtrim(string $characters = null)
Right trim the string of the given characters.
Stringable
ucfirst()
Make a string's first character uppercase.
mixed|$this
when(mixed $value, callable $callback, callable|null $default = null)
Apply the callback's string changes if the given "value" is true.
Stringable
whenEmpty(callable $callback)
Execute the given callback if the string is empty.
Stringable
words(int $words = 100, string $end = '...')
Limit the number of words in a string.
$this
dump()
Dump the string.
void
dd()
Dump the string and end the script.
mixed
__get(string $key)
Proxy dynamic properties onto methods.
string
__toString()
Get the raw string value.