Str
String helper
class Winter\Storm\Support\Str
extends Illuminate\Support\Str
Extends
Class | Description |
---|---|
Illuminate\Support\Str
|
Methods
public static getClassId ($name)
Generates a class ID from either an object or a string of the class name.
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
public static getClassNamespace ($name)
Returns a class namespace
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
public static getPrecedingSymbols (string $string, string $symbol) : int
If $string begins with any number of consecutive symbols, returns the number, otherwise returns 0
Property | Type | Description |
---|---|---|
$string | string |
string
|
$symbol | string |
string
|
public static isJson ($value) : bool
Check if the provided input is a valid JSON string.
Property | Type | Description |
---|---|---|
$value | mixed |
mixed
|
public
static
join (iterable $items, string $glue = ", "
, string $lastGlue = ", and "
, string $dyadicGlue = " and "
)
: string
Join items into a human readable list (e.g. "one, two, three, and four") Uses different glue strings when there are only two elements and for the final element. Defaults to joining using the Oxford comma.
1 item will return: $item 2 items will return: $item1 . $dyadicGlue . $item2 3+ items will return: $item1 . $glue . $item2 . $lastGlue . $item3
Property | Type | Description |
---|---|---|
$items | iterable |
iterable
|
$glue | string |
string
|
$lastGlue | string |
string
|
$dyadicGlue | string |
string
|
public static normalizeClassName ($name)
Removes the starting slash from a class namespace \
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
public static normalizeEol ($string)
Converts line breaks to a standard \r\n pattern.
Property | Type | Description |
---|---|---|
$string | mixed |
mixed
|
public static ordinal (int $number) : string
Converts number to its ordinal English form.
This method converts 13 to 13th, 2 to 2nd ...
Property | Type | Description |
---|---|---|
$number | int |
int
Number to get its ordinal value |
Ordinal representation of given string.
public
static
unique (string $str, array $items, string $separator = "_"
, integer $step = 1
)
: string
Ensures that the provide string will be unique within the provided array, adjusts it with the separator & step as necessary if not
Examples: winter, [winter, winter_1, winter_2] -> winter_3 winter, [winter_1, winter_3] -> winter
Property | Type | Description |
---|---|---|
$str | string |
string
|
$items | array |
array
|
$separator | string |
string
|
$step | integer |
integer
|