Str

String helper

 class Winter\Storm\Support\Str
extends Illuminate\Support\Str

Methods

public static getClassId ($name)

Generates a class ID from either an object or a string of the class name.

Parameters
Property Description
$name
mixed
Returns
mixed

public static getClassNamespace ($name)

Returns a class namespace

Parameters
Property Description
$name
mixed
Returns
mixed

public static getPrecedingSymbols (string $string, string $symbol) : int

If $string begins with any number of consecutive symbols, returns the number, otherwise returns 0

Parameters
Property Description
$string
string
$symbol
string
Returns
int

public static isJson ($value) : bool

Check if the provided input is a valid JSON string.

Parameters
Property Description
$value
mixed
Returns
bool

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

Parameters
Property Description
$items
iterable
$glue
string
$lastGlue
string
$dyadicGlue
string
Returns
string

public static normalizeClassName ($name)

Removes the starting slash from a class namespace \

Parameters
Property Description
$name
mixed
Returns
mixed

public static normalizeEol ($string)

Converts line breaks to a standard \r\n pattern.

Parameters
Property Description
$string
mixed
Returns
mixed

public static ordinal (int $number) : string

Converts number to its ordinal English form.

This method converts 13 to 13th, 2 to 2nd ...

Parameters
Property Description
$number
int

Number to get its ordinal value

Returns
string

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

Parameters
Property Description
$str
string
$items
array
$separator
string
$step
integer
Returns
string
Copyright © 2024 Winter CMS