Str
class Str
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| 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
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Return the remainder of a string after a given value.
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.
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.
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.
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.
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.
Make a string's first character uppercase.
Returns the replacements for the ascii method.
Details
in
Macroable at line 24
static void
macro(string $name, callable $macro)
Register a custom macro.
in
Macroable at line 35
static bool
hasMacro(string $name)
Checks if macro is registered.
in
Macroable at line 49
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 71
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 39
static string
after(string $subject, string $search)
Return the remainder of a string after a given value.
at line 60
static string
ascii(string $value)
Transliterate a UTF-8 value to ASCII.
at line 75
static string
camel(string $value)
Convert a value to camel case.
at line 91
static bool
contains(string $haystack, string|array $needles)
Determine if a given string contains a given substring.
at line 109
static bool
endsWith(string $haystack, string|array $needles)
Determine if a given string ends with a given substring.
at line 127
static string
finish(string $value, string $cap)
Cap a string with a single instance of a given value.
at line 141
static bool
is(string $pattern, string $value)
Determine if a given string matches a given pattern.
at line 163
static string
kebab(string $value)
Convert a string to kebab case.
at line 175
static int
length(string $value, string $encoding = null)
Return the length of the given string.
at line 192
static string
limit(string $value, int $limit = 100, string $end = '...')
Limit the number of characters in a string.
at line 207
static string
lower(string $value)
Convert the given string to lower-case.
at line 220
static string
words(string $value, int $words = 100, string $end = '...')
Limit the number of words in a string.
at line 238
static array
parseCallback(string $callback, string|null $default = null)
Parse a Class@method style callback into class and method.
at line 250
static string
plural(string $value, int $count = 2)
Get the plural form of an English word.
at line 261
static string
random(int $length = 16)
Generate a more truly "random" alpha-numeric string.
at line 286
static string
quickRandom(int $length = 16)
deprecated
deprecated
Generate a "random" alpha-numeric string.
Should not be considered sufficient for cryptography, etc.
at line 305
static string
replaceArray(string $search, array $replace, string $subject)
Replace a given value in the string sequentially with an array.
at line 322
static string
replaceFirst(string $search, string $replace, string $subject)
Replace the first occurrence of a given value in the string.
at line 345
static string
replaceLast(string $search, string $replace, string $subject)
Replace the last occurrence of a given value in the string.
at line 363
static string
start(string $value, string $prefix)
Begin a string with a single instance of a given value.
at line 376
static string
upper(string $value)
Convert the given string to upper-case.
at line 387
static string
title(string $value)
Convert the given string to title case.
at line 398
static string
singular(string $value)
Get the singular form of an English word.
at line 410
static string
slug(string $title, string $separator = '-')
Generate a URL friendly "slug" from a given string.
at line 435
static string
snake(string $value, string $delimiter = '_')
Convert a string to snake case.
at line 459
static bool
startsWith(string $haystack, string|array $needles)
Determine if a given string starts with a given substring.
at line 476
static string
studly(string $value)
Convert a value to studly caps case.
at line 497
static string
substr(string $string, int $start, int|null $length = null)
Returns the portion of string specified by the start and length parameters.
at line 508
static string
ucfirst(string $string)
Make a string's first character uppercase.
at line 522
static protected array
charsArray()
Returns the replacements for the ascii method.
Note: Adapted from Stringy\Stringy.