Str
class Str
Collection of string manipulation methods.
Constants
ALNUM |
Alphanumeric characters. |
ALPHA |
Alphabetic characters. |
HEXDEC |
Hexadecimal characters. |
NUMERIC |
Numeric characters. |
SYMBOLS |
ASCII symbols. |
Properties
static protected array | $pluralizationRules | Pluralization rules. | |
static protected array | $irregulars | Irregular nouns. |
Methods
Replaces newline with
or
.
Replaces
and
with newline.
Returns the plural form of a noun (english only).
Converts camel case to underscored.
Converts underscored to camel case.
Limits the number of characters in a string.
Limits the number of words in a string.
Creates a URL friendly string.
Strips all non-ASCII characters.
Returns a closure that will alternate between the defined strings.
Converts URLs in a text into clickable links.
Returns a masked string where only the last n characters are visible.
Increments a string by appending a number to it or increasing the number.
Returns a random string of the selected type and length.
Details
at line 133
static string
nl2br(string $string, bool $xhtml = false)
Replaces newline with
or
.
at line 144
static string
br2nl(string $string)
Replaces
and
with newline.
at line 156
static string
pluralize(string $noun, int|null $count = null)
Returns the plural form of a noun (english only).
at line 187
static string
camel2underscored(string $string)
Converts camel case to underscored.
at line 199
static string
underscored2camel(string $string, bool $upper = false)
Converts underscored to camel case.
at line 215
static string
limitChars(string $string, int $characters = 100, string $sufix = '...')
Limits the number of characters in a string.
at line 228
static string
limitWords(string $string, int $words = 100, string $sufix = '...')
Limits the number of words in a string.
at line 246
static string
slug(string $string)
Creates a URL friendly string.
at line 257
static string
ascii(string $string)
Strips all non-ASCII characters.
at line 268
static Closure
alternator(array $strings)
Returns a closure that will alternate between the defined strings.
at line 285
static string
autolink(string $string, array $attributes = [])
Converts URLs in a text into clickable links.
at line 301
static string
mask(string $string, int $visible = 3, string $mask = '*')
Returns a masked string where only the last n characters are visible.
at line 321
static string
increment(string $string, int $start = 1, string $separator = '_')
Increments a string by appending a number to it or increasing the number.
at line 335
static string
random(string $pool = Str::ALNUM, int $length = 32)
Returns a random string of the selected type and length.