Str
class Str (View source)
Traits
Macroable |
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
static void | macro(string $name, object|callable $macro) Register a custom macro. | from Macroable |
static void | mixin(object $mixin) Mix another object into the class. | from Macroable |
static bool | hasMacro(string $name) Checks if macro is registered. | from Macroable |
static mixed | __callStatic(string $method, array $parameters) Dynamically handle calls to the class. | from Macroable |
mixed | __call(string $method, array $parameters) Dynamically handle calls to the class. | from Macroable |
static string | after(string $subject, string $search) Return the remainder of a string after a given value. | |
static string | ascii(string $value, string $language = 'en') Transliterate a UTF-8 value to ASCII. | |
static string | before(string $subject, string $search) Get the portion of a string before a given value. | |
static string | camel(string $value) Convert a value to camel case. | |
static bool | contains(string $haystack, string|array $needles) Determine if a given string contains a given substring. | |
static bool | endsWith(string $haystack, string|array $needles) Determine if a given string ends with a given substring. | |
static string | finish(string $value, string $cap) Cap a string with a single instance of a given value. | |
static bool | is(string|array $pattern, string $value) Determine if a given string matches a given pattern. | |
static string | kebab(string $value) Convert a string to kebab case. | |
static int | length(string $value, string $encoding = null) Return the length of the given string. | |
static string | limit(string $value, int $limit = 100, string $end = '...') Limit the number of characters in a string. | |
static string | lower(string $value) Convert the given string to lower-case. | |
static string | words(string $value, int $words = 100, string $end = '...') Limit the number of words in a string. | |
static array | parseCallback(string $callback, string|null $default = null) Parse a Class@method style callback into class and method. | |
static string | plural(string $value, int $count = 2) Get the plural form of an English word. | |
static string | random(int $length = 16) Generate a more truly "random" alpha-numeric string. | |
static string | replaceArray(string $search, array $replace, string $subject) Replace a given value in the string sequentially with an array. | |
static string | replaceFirst(string $search, string $replace, string $subject) Replace the first occurrence of a given value in the string. | |
static string | replaceLast(string $search, string $replace, string $subject) Replace the last occurrence of a given value in the string. | |
static string | start(string $value, string $prefix) Begin a string with a single instance of a given value. | |
static string | upper(string $value) Convert the given string to upper-case. | |
static string | title(string $value) Convert the given string to title case. | |
static string | singular(string $value) Get the singular form of an English word. | |
static string | slug(string $title, string $separator = '-', string $language = 'en') Generate a URL friendly "slug" from a given string. | |
static string | snake(string $value, string $delimiter = '_') Convert a string to snake case. | |
static bool | startsWith(string $haystack, string|array $needles) Determine if a given string starts with a given substring. | |
static string | studly(string $value) Convert a value to studly caps case. | |
static string | substr(string $string, int $start, int|null $length = null) Returns the portion of string specified by the start and length parameters. | |
static string | ucfirst(string $string) Make a string's first character uppercase. | |
static UuidInterface | uuid() Generate a UUID (version 4). | |
static UuidInterface | orderedUuid() Generate a time-ordered UUID (version 4). | |
static array | charsArray() Returns the replacements for the ascii method. | |
static array|null | languageSpecificCharsArray(string $language) Returns the language specific replacements for the ascii method. |
Details
static void macro(string $name, object|callable $macro)
Register a custom macro.
static void mixin(object $mixin)
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.
static string after(string $subject, string $search)
Return the remainder of a string after a given value.
static string ascii(string $value, string $language = 'en')
Transliterate a UTF-8 value to ASCII.
static string before(string $subject, string $search)
Get the portion of a string before a given value.
static string camel(string $value)
Convert a value to camel case.
static bool contains(string $haystack, string|array $needles)
Determine if a given string contains a given substring.
static bool endsWith(string $haystack, string|array $needles)
Determine if a given string ends with a given substring.
static string finish(string $value, string $cap)
Cap a string with a single instance of a given value.
static bool is(string|array $pattern, string $value)
Determine if a given string matches a given pattern.
static string kebab(string $value)
Convert a string to kebab case.
static int length(string $value, string $encoding = null)
Return the length of the given string.
static string limit(string $value, int $limit = 100, string $end = '...')
Limit the number of characters in a string.
static string lower(string $value)
Convert the given string to lower-case.
static string words(string $value, int $words = 100, string $end = '...')
Limit the number of words in a string.
static array parseCallback(string $callback, string|null $default = null)
Parse a Class@method style callback into class and method.
static string plural(string $value, int $count = 2)
Get the plural form of an English word.
static string random(int $length = 16)
Generate a more truly "random" alpha-numeric string.
static string replaceArray(string $search, array $replace, string $subject)
Replace a given value in the string sequentially with an array.
static string replaceFirst(string $search, string $replace, string $subject)
Replace the first occurrence of a given value in the string.
static string replaceLast(string $search, string $replace, string $subject)
Replace the last occurrence of a given value in the string.
static string start(string $value, string $prefix)
Begin a string with a single instance of a given value.
static string upper(string $value)
Convert the given string to upper-case.
static string title(string $value)
Convert the given string to title case.
static string singular(string $value)
Get the singular form of an English word.
static string slug(string $title, string $separator = '-', string $language = 'en')
Generate a URL friendly "slug" from a given string.
static string snake(string $value, string $delimiter = '_')
Convert a string to snake case.
static bool startsWith(string $haystack, string|array $needles)
Determine if a given string starts with a given substring.
static string studly(string $value)
Convert a value to studly caps case.
static string substr(string $string, int $start, int|null $length = null)
Returns the portion of string specified by the start and length parameters.
static string ucfirst(string $string)
Make a string's first character uppercase.
static UuidInterface uuid()
Generate a UUID (version 4).
static UuidInterface orderedUuid()
Generate a time-ordered UUID (version 4).
static protected array charsArray()
Returns the replacements for the ascii method.
Note: Adapted from Stringy\Stringy.
static protected array|null languageSpecificCharsArray(string $language)
Returns the language specific replacements for the ascii method.
Note: Adapted from Stringy\Stringy.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.7/Illuminate/Support/Str.html