\Omega\Support Str

Str class.

The 'Str' class provides a collection of static methods for string manipulation and handling. This utility class offers various functions for common string operations such as concatenation, substring extraction, trimming, case conversion, and pattern matching. By encapsulating these functionalities within a single class, 'Str' simplifies string processing tasks and promotes code reusability. Developers can utilize the methods provided by 'Str' to efficiently work with strings in their applications, enhancing readability, maintainability, and overall code quality.

Summary

Methods
Properties
Constants
ascii
is
lower
slug
startsWith
strlen
strContains
No public properties found
No public constants found
charsArray
languageSpecificCharsArray
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Methods

ascii()

ascii(string  $value, string  $language = 'en') : string

Transliterate a UTF-8 value to ascii.

Parameters

string $value

Holds the value to transliterate.

string $language

Holds the language to transliterate.

Returns

string —

Return the transliterated ascii value.

is()

is(string|array  $pattern, string  $value) : bool

Determine if a given string matches the given patterns.

Parameters

string|array $pattern

Holds the pattern to match.

string $value

Holds the value to check.

Returns

bool —

Return true if the given string match, false if not.

lower()

lower(string  $value) : string

Convert the given string to lower-case.

Parameters

string $value

Holds the string to convert.

Returns

string —

Return the converted string.

slug()

slug(string  $title, string  $separator = '-', string|null  $language = 'en') : string

Generate a URL friendly "slug" from a given string.

Parameters

string $title
string $separator
string|null $language

Returns

string —

startsWith()

startsWith(string  $haystack, string|array  $needles) : bool

Determine if a given string starts with a given substring.

Parameters

string $haystack

Holds the main string to search within.

string|array $needles

Holds the substring to search for within the main string.

Returns

bool —

Return true if a string starts with a given substring, false if not.

strlen()

strlen(string  $string, string  $encoding = 'UTF-8') : int

Returns the length of a string using mb_strlen if available, otherwise falls back to strlen.

Parameters

string $string

The string to measure.

string $encoding

The character encoding, default is 'UTF-8'.

Returns

int —

The length of the string.

strContains()

strContains(string  $haystack, string  $needle) : bool

Checks if a string contains another string.

Parameters

string $haystack

The string to search in.

string $needle

The substring to search for.

Returns

bool —

Returns true if the substring is found, false otherwise.

charsArray()

charsArray() : array

Returns the replacements for the ascii method.

Note: Adapted from Stringy\Stringy.

Returns

array —

Return the replacements for the ascii method.

languageSpecificCharsArray()

languageSpecificCharsArray(string  $language) : ?array

Returns the language specific replacements for the ascii method.

Parameters

string $language

Holds the language specific replacements.

Returns

?array —

Return an array of specific replacements or null.