Helpers
This is a special class that should *NEVER* be touched.
The methods contained here are a list of methods coming from the laravel framework.
When scoping dependencies, unfortunately not all methods can be automatically patched. Therefore the scoping configuration overwrites the usage of global functions such as "value()" by prefixing them with the \Barn2\Plugin\WC_Product_Options\ namespace and calls the methods from the Helpers class below here.
Tags
Table of Contents
- array_add() : array<string|int, mixed>
- Add an element to an array using "dot" notation if it doesn't exist.
- array_collapse() : array<string|int, mixed>
- Collapse an array of arrays into a single array.
- array_divide() : array<string|int, mixed>
- Divide an array into two arrays. One with keys and the other with values.
- array_dot() : array<string|int, mixed>
- Flatten a multi-dimensional associative array with dots.
- array_except() : array<string|int, mixed>
- Get all of the given array except for a specified array of keys.
- array_first() : mixed
- Return the first element in an array passing a given truth test.
- array_flatten() : array<string|int, mixed>
- Flatten a multi-dimensional array into a single level.
- array_forget() : void
- Remove one or many array items from a given array using "dot" notation.
- array_get() : mixed
- Get an item from an array using "dot" notation.
- array_has() : bool
- Check if an item or items exist in an array using "dot" notation.
- array_last() : mixed
- Return the last element in an array passing a given truth test.
- array_only() : array<string|int, mixed>
- Get a subset of the items from the given array.
- array_pluck() : array<string|int, mixed>
- Pluck an array of values from an array.
- array_prepend() : array<string|int, mixed>
- Push an item onto the beginning of an array.
- array_pull() : mixed
- Get a value from the array, and remove it.
- array_random() : mixed
- Get a random value from an array.
- array_set() : array<string|int, mixed>
- Set an array item to a given value using "dot" notation.
- array_sort() : array<string|int, mixed>
- Sort the array by the given callback or attribute name.
- array_sort_recursive() : array<string|int, mixed>
- Recursively sort an array by keys and values.
- array_where() : array<string|int, mixed>
- Filter the array using the given callback.
- array_wrap() : array<string|int, mixed>
- If the given value is not an array, wrap it in one.
- blank() : bool
- Determine if the given value is "blank".
- camel_case() : string
- Convert a value to camel case.
- class_basename() : string
- Get the class "basename" of the given object / class.
- class_uses_recursive() : array<string|int, mixed>
- Returns all traits used by a class, its parent classes and trait of their traits.
- collect() : Collection
- Create a collection from the given value.
- data_fill() : mixed
- Fill in data where it's missing.
- data_get() : mixed
- Get an item from an array or object using "dot" notation.
- data_set() : mixed
- Set an item on an array or object using dot notation.
- ends_with() : bool
- Determine if a given string ends with a given substring.
- head() : mixed
- Get the first element of an array. Useful for method chaining.
- kebab_case() : string
- Convert a string to kebab case.
- last() : mixed
- Get the last element from an array.
- snake_case() : string
- Convert a string to snake case.
- starts_with() : bool
- Determine if a given string starts with a given substring.
- str_after() : string
- Return the remainder of a string after a given value.
- str_before() : string
- Get the portion of a string before a given value.
- str_contains() : bool
- Determine if a given string contains a given substring.
- str_finish() : string
- Cap a string with a single instance of a given value.
- str_is() : bool
- Determine if a given string matches a given pattern.
- str_limit() : string
- Limit the number of characters in a string.
- str_plural() : string
- Get the plural form of an English word.
- str_random() : string
- Generate a more truly "random" alpha-numeric string.
- str_replace_array() : string
- Replace a given value in the string sequentially with an array.
- str_replace_first() : string
- Replace the first occurrence of a given value in the string.
- str_replace_last() : string
- Replace the last occurrence of a given value in the string.
- str_singular() : string
- Get the singular form of an English word.
- str_slug() : string
- Generate a URL friendly "slug" from a given string.
- str_start() : string
- Begin a string with a single instance of a given value.
- studly_case() : string
- Convert a value to studly caps case.
- tap() : mixed
- Call the given Closure with the given value then return the value.
- title_case() : string
- Convert a value to title case.
- trait_uses_recursive() : array<string|int, mixed>
- Returns all traits used by a trait and its traits.
- transform() : mixed|null
- Transform the given value if it is present.
- value() : mixed
- Return the default value of the given value.
- windows_os() : bool
- Determine whether the current environment is Windows based.
Methods
array_add()
Add an element to an array using "dot" notation if it doesn't exist.
public
static array_add(array<string|int, mixed> $array, string $key, mixed $value) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $key : string
- $value : mixed
Tags
Return values
array<string|int, mixed> —array_collapse()
Collapse an array of arrays into a single array.
public
static array_collapse(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —array_divide()
Divide an array into two arrays. One with keys and the other with values.
public
static array_divide(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —array_dot()
Flatten a multi-dimensional associative array with dots.
public
static array_dot(array<string|int, mixed> $array[, string $prepend = '' ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $prepend : string = ''
Tags
Return values
array<string|int, mixed> —array_except()
Get all of the given array except for a specified array of keys.
public
static array_except(array<string|int, mixed> $array, array<string|int, mixed>|string $keys) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $keys : array<string|int, mixed>|string
Tags
Return values
array<string|int, mixed> —array_first()
Return the first element in an array passing a given truth test.
public
static array_first(array<string|int, mixed> $array[, callable|null $callback = null ][, mixed $default = null ]) : mixed
Parameters
- $array : array<string|int, mixed>
- $callback : callable|null = null
- $default : mixed = null
Tags
Return values
mixed —array_flatten()
Flatten a multi-dimensional array into a single level.
public
static array_flatten(array<string|int, mixed> $array[, int $depth = INF ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $depth : int = INF
Tags
Return values
array<string|int, mixed> —array_forget()
Remove one or many array items from a given array using "dot" notation.
public
static array_forget(array<string|int, mixed> &$array, array<string|int, mixed>|string $keys) : void
Parameters
- $array : array<string|int, mixed>
- $keys : array<string|int, mixed>|string
Tags
Return values
void —array_get()
Get an item from an array using "dot" notation.
public
static array_get(ArrayAccess|array<string|int, mixed> $array, string|int $key[, mixed $default = null ]) : mixed
Parameters
- $array : ArrayAccess|array<string|int, mixed>
- $key : string|int
- $default : mixed = null
Tags
Return values
mixed —array_has()
Check if an item or items exist in an array using "dot" notation.
public
static array_has(ArrayAccess|array<string|int, mixed> $array, string|array<string|int, mixed> $keys) : bool
Parameters
- $array : ArrayAccess|array<string|int, mixed>
- $keys : string|array<string|int, mixed>
Tags
Return values
bool —array_last()
Return the last element in an array passing a given truth test.
public
static array_last(array<string|int, mixed> $array[, callable|null $callback = null ][, mixed $default = null ]) : mixed
Parameters
- $array : array<string|int, mixed>
- $callback : callable|null = null
- $default : mixed = null
Tags
Return values
mixed —array_only()
Get a subset of the items from the given array.
public
static array_only(array<string|int, mixed> $array, array<string|int, mixed>|string $keys) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $keys : array<string|int, mixed>|string
Tags
Return values
array<string|int, mixed> —array_pluck()
Pluck an array of values from an array.
public
static array_pluck(array<string|int, mixed> $array, string|array<string|int, mixed> $value[, string|array<string|int, mixed>|null $key = null ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $value : string|array<string|int, mixed>
- $key : string|array<string|int, mixed>|null = null
Tags
Return values
array<string|int, mixed> —array_prepend()
Push an item onto the beginning of an array.
public
static array_prepend(array<string|int, mixed> $array, mixed $value[, mixed $key = null ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $value : mixed
- $key : mixed = null
Tags
Return values
array<string|int, mixed> —array_pull()
Get a value from the array, and remove it.
public
static array_pull(array<string|int, mixed> &$array, string $key[, mixed $default = null ]) : mixed
Parameters
- $array : array<string|int, mixed>
- $key : string
- $default : mixed = null
Tags
Return values
mixed —array_random()
Get a random value from an array.
public
static array_random(array<string|int, mixed> $array[, int|null $num = null ]) : mixed
Parameters
- $array : array<string|int, mixed>
- $num : int|null = null
Tags
Return values
mixed —array_set()
Set an array item to a given value using "dot" notation.
public
static array_set(array<string|int, mixed> &$array, string $key, mixed $value) : array<string|int, mixed>
If no key is given to the method, the entire array will be replaced.
Parameters
- $array : array<string|int, mixed>
- $key : string
- $value : mixed
Tags
Return values
array<string|int, mixed> —array_sort()
Sort the array by the given callback or attribute name.
public
static array_sort(array<string|int, mixed> $array[, callable|string|null $callback = null ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $callback : callable|string|null = null
Tags
Return values
array<string|int, mixed> —array_sort_recursive()
Recursively sort an array by keys and values.
public
static array_sort_recursive(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —array_where()
Filter the array using the given callback.
public
static array_where(array<string|int, mixed> $array, callable $callback) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
- $callback : callable
Tags
Return values
array<string|int, mixed> —array_wrap()
If the given value is not an array, wrap it in one.
public
static array_wrap(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
Tags
Return values
array<string|int, mixed> —blank()
Determine if the given value is "blank".
public
static blank(mixed $value) : bool
Parameters
- $value : mixed
Tags
Return values
bool —camel_case()
Convert a value to camel case.
public
static camel_case(string $value) : string
Parameters
- $value : string
Tags
Return values
string —class_basename()
Get the class "basename" of the given object / class.
public
static class_basename(string|object $class) : string
Parameters
- $class : string|object
Tags
Return values
string —class_uses_recursive()
Returns all traits used by a class, its parent classes and trait of their traits.
public
static class_uses_recursive(object|string $class) : array<string|int, mixed>
Parameters
- $class : object|string
Tags
Return values
array<string|int, mixed> —collect()
Create a collection from the given value.
public
static collect([mixed $value = null ]) : Collection
Parameters
- $value : mixed = null
Tags
Return values
Collection —data_fill()
Fill in data where it's missing.
public
static data_fill(mixed &$target, string|array<string|int, mixed> $key, mixed $value) : mixed
Parameters
- $target : mixed
- $key : string|array<string|int, mixed>
- $value : mixed
Tags
Return values
mixed —data_get()
Get an item from an array or object using "dot" notation.
public
static data_get(mixed $target, string|array<string|int, mixed>|int|null $key[, mixed $default = null ]) : mixed
Parameters
- $target : mixed
- $key : string|array<string|int, mixed>|int|null
- $default : mixed = null
Tags
Return values
mixed —data_set()
Set an item on an array or object using dot notation.
public
static data_set(mixed &$target, string|array<string|int, mixed> $key, mixed $value[, bool $overwrite = true ]) : mixed
Parameters
- $target : mixed
- $key : string|array<string|int, mixed>
- $value : mixed
- $overwrite : bool = true
Tags
Return values
mixed —ends_with()
Determine if a given string ends with a given substring.
public
static ends_with(string $haystack, string|array<string|int, mixed> $needles) : bool
Parameters
- $haystack : string
- $needles : string|array<string|int, mixed>
Tags
Return values
bool —head()
Get the first element of an array. Useful for method chaining.
public
static head(array<string|int, mixed> $array) : mixed
Parameters
- $array : array<string|int, mixed>
Tags
Return values
mixed —kebab_case()
Convert a string to kebab case.
public
static kebab_case(string $value) : string
Parameters
- $value : string
Tags
Return values
string —last()
Get the last element from an array.
public
static last(array<string|int, mixed> $array) : mixed
Parameters
- $array : array<string|int, mixed>
Tags
Return values
mixed —snake_case()
Convert a string to snake case.
public
static snake_case(string $value[, string $delimiter = '_' ]) : string
Parameters
- $value : string
- $delimiter : string = '_'
Tags
Return values
string —starts_with()
Determine if a given string starts with a given substring.
public
static starts_with(string $haystack, string|array<string|int, mixed> $needles) : bool
Parameters
- $haystack : string
- $needles : string|array<string|int, mixed>
Tags
Return values
bool —str_after()
Return the remainder of a string after a given value.
public
static str_after(string $subject, string $search) : string
Parameters
- $subject : string
- $search : string
Tags
Return values
string —str_before()
Get the portion of a string before a given value.
public
static str_before(string $subject, string $search) : string
Parameters
- $subject : string
- $search : string
Tags
Return values
string —str_contains()
Determine if a given string contains a given substring.
public
static str_contains(string $haystack, string|array<string|int, mixed> $needles) : bool
Parameters
- $haystack : string
- $needles : string|array<string|int, mixed>
Tags
Return values
bool —str_finish()
Cap a string with a single instance of a given value.
public
static str_finish(string $value, string $cap) : string
Parameters
- $value : string
- $cap : string
Tags
Return values
string —str_is()
Determine if a given string matches a given pattern.
public
static str_is(string|array<string|int, mixed> $pattern, string $value) : bool
Parameters
- $pattern : string|array<string|int, mixed>
- $value : string
Tags
Return values
bool —str_limit()
Limit the number of characters in a string.
public
static str_limit(string $value[, int $limit = 100 ][, string $end = '...' ]) : string
Parameters
- $value : string
- $limit : int = 100
- $end : string = '...'
Tags
Return values
string —str_plural()
Get the plural form of an English word.
public
static str_plural(string $value[, int $count = 2 ]) : string
Parameters
- $value : string
- $count : int = 2
Tags
Return values
string —str_random()
Generate a more truly "random" alpha-numeric string.
public
static str_random([int $length = 16 ]) : string
Parameters
- $length : int = 16
Tags
Return values
string —str_replace_array()
Replace a given value in the string sequentially with an array.
public
static str_replace_array(string $search, array<string|int, mixed> $replace, string $subject) : string
Parameters
- $search : string
- $replace : array<string|int, mixed>
- $subject : string
Tags
Return values
string —str_replace_first()
Replace the first occurrence of a given value in the string.
public
static str_replace_first(string $search, string $replace, string $subject) : string
Parameters
- $search : string
- $replace : string
- $subject : string
Tags
Return values
string —str_replace_last()
Replace the last occurrence of a given value in the string.
public
static str_replace_last(string $search, string $replace, string $subject) : string
Parameters
- $search : string
- $replace : string
- $subject : string
Tags
Return values
string —str_singular()
Get the singular form of an English word.
public
static str_singular(string $value) : string
Parameters
- $value : string
Tags
Return values
string —str_slug()
Generate a URL friendly "slug" from a given string.
public
static str_slug(string $title[, string $separator = '-' ][, string $language = 'en' ]) : string
Parameters
- $title : string
- $separator : string = '-'
- $language : string = 'en'
Tags
Return values
string —str_start()
Begin a string with a single instance of a given value.
public
static str_start(string $value, string $prefix) : string
Parameters
- $value : string
- $prefix : string
Tags
Return values
string —studly_case()
Convert a value to studly caps case.
public
static studly_case(string $value) : string
Parameters
- $value : string
Tags
Return values
string —tap()
Call the given Closure with the given value then return the value.
public
static tap(mixed $value[, callable|null $callback = null ]) : mixed
Parameters
- $value : mixed
- $callback : callable|null = null
Tags
Return values
mixed —title_case()
Convert a value to title case.
public
static title_case(string $value) : string
Parameters
- $value : string
Tags
Return values
string —trait_uses_recursive()
Returns all traits used by a trait and its traits.
public
static trait_uses_recursive(string $trait) : array<string|int, mixed>
Parameters
- $trait : string
Tags
Return values
array<string|int, mixed> —transform()
Transform the given value if it is present.
public
static transform(mixed $value, callable $callback[, mixed $default = null ]) : mixed|null
Parameters
- $value : mixed
- $callback : callable
- $default : mixed = null
Tags
Return values
mixed|null —value()
Return the default value of the given value.
public
static value(mixed $value, mixed ...$args) : mixed
Parameters
- $value : mixed
- $args : mixed
Tags
Return values
mixed —windows_os()
Determine whether the current environment is Windows based.
public
static windows_os() : bool