Arrayable
in package
Uses
Microable
Table of Contents
Properties
Methods
- __call() : mixed
- Dynamically handle calls to the class.
- __callStatic() : mixed
- Dynamically handle calls to the class.
- __construct() : mixed
- __get() : mixed
- __isset() : mixed
- __set() : mixed
- __toString() : string
- __unset() : mixed
- add() : Arrayable
- Add a key value pair to the array If only the key is provided, the key will be the value
- addAfter() : static
- addAtKey() : $this
- Adds the $value to the current value of $key.
- addBefore() : static
- all() : array<string|int, mixed>
- arrayType() : string
- Get the type of the array
- at() : mixed
- Get the value at a certain index
- chunk() : Arrayable
- Chunk the array
- differenceFrom() : Arrayable
- Returns the items in the current array that are not in the other array
- each() : Arrayable
- Each through the array
- filter() : Arrayable
- Filter the array
- first() : false|mixed
- Get the first item in the array
- flush() : $this
- Reset the array
- flushMacros() : void
- Remove all the macros we had registered
- get() : mixed
- Get an item from the array
- getA() : mixed
- getArray() : array<string|int, mixed>|null
- getArrayable() : Arrayable|null
- getBool() : bool|null
- getFloat() : float|null
- getInt() : int|null
- getJson() : false|string|null
- getNegativeInteger() : int|null
- getOrThrow() : mixed
- getPositiveInteger() : int|null
- getString() : string|null
- has() : bool
- Check if the array has a key
- hasMacro() : bool
- Check if we have a method in the balonables
- isAssoc() : bool
- Checks if an array is associative
- isEmpty() : bool
- Checks if the array is empty
- isFilled() : bool
- isMixed() : bool
- Checks if an array has both numeric and string keys
- keys() : array<string|int, mixed>
- Get the keys of the array
- keysToLowerCase() : $this
- Convert the keys of the array to lowercase
- keysToUpperCase() : $this
- Convert the keys of the array to uppercase
- last() : false|mixed
- Get the last item in the array
- macro() : void
- Add a new mixable to the macros
- map() : Arrayable
- Map through the array
- mapWithKeys() : Arrayable
- Map through the array and flatten the result to a single array of values by using the callback
- merge() : Arrayable
- Merge a whole into the current array
- mixin() : void
- Mix another object into the class.
- only() : Arrayable
- Get a subset of the items from the given array.
- pop() : mixed
- reduce() : Arrayable
- Reduce the array
- remove() : Arrayable
- Remove an item from the array
- replace() : static
- reverse() : Arrayable
- Reverse the array
- set() : $this
- Set an item in the array by key and value
- shift() : mixed
- size() : int
- Get the size of the array
- slice() : $this
- Slice the array
- sort() : Arrayable
- Sort the array
- sortKeys() : Arrayable
- Sort the keys of the array
- sortValues() : Arrayable
- Sort the values of the array
- toArray() : array<string|int, mixed>
- Convert the arrayable object to an array
- toArrayable() : Arrayable
- toJson() : string
- Convert the arrayable to json
- type() : string
- Return the type of the underlying array object
- unshift() : static
- values() : array<string|int, mixed>
- Get the values of the array
- valuesToLowerCase() : Arrayable
- Convert the values of the array to lowercase
- where() : Arrayable
- Filter the array using the given callback.
Properties
$macros
protected
static array<string|int, mixed>
$macros
= []
$array
The array to be manipulated
private
array<string|int, mixed>
$array
= []
Methods
__call()
Dynamically handle calls to the class.
public
__call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
__callStatic()
Dynamically handle calls to the class.
public
static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
__construct()
public
__construct([array<string|int, mixed> $array = [] ]) : mixed
Parameters
- $array : array<string|int, mixed> = []
__get()
public
__get(mixed $name) : mixed
Parameters
- $name : mixed
__isset()
public
__isset(mixed $name) : mixed
Parameters
- $name : mixed
__set()
public
__set(mixed $name, mixed $value) : mixed
Parameters
- $name : mixed
- $value : mixed
__toString()
public
__toString() : string
Return values
string__unset()
public
__unset(mixed $name) : mixed
Parameters
- $name : mixed
add()
Add a key value pair to the array If only the key is provided, the key will be the value
public
add(string $key[, mixed|null $value = null ]) : Arrayable
Parameters
- $key : string
- $value : mixed|null = null
Return values
ArrayableaddAfter()
public
addAfter(mixed $positionKey, mixed $key[, mixed $value = null ]) : static
Parameters
- $positionKey : mixed
- $key : mixed
- $value : mixed = null
Return values
staticaddAtKey()
Adds the $value to the current value of $key.
public
addAtKey(string $key, mixed $value) : $this
If the value is numeric, it will be added to the current value If the value is a string, it will be concatenated to the current value If the value is an array, it will be merged with the current value
Parameters
- $key : string
- $value : mixed
Return values
$thisaddBefore()
public
addBefore(string $positionKey, string $key[, mixed $value = null ]) : static
Parameters
- $positionKey : string
- $key : string
- $value : mixed = null
Return values
staticall()
public
all() : array<string|int, mixed>
Return values
array<string|int, mixed>arrayType()
Get the type of the array
public
arrayType([array<string|int, mixed>|null $arr = null ]) : string
Parameters
- $arr : array<string|int, mixed>|null = null
Return values
stringat()
Get the value at a certain index
public
at(int $index) : mixed
Parameters
- $index : int
chunk()
Chunk the array
public
chunk(int $size[, bool $preserve_keys = false ]) : Arrayable
Parameters
- $size : int
- $preserve_keys : bool = false
Return values
ArrayabledifferenceFrom()
Returns the items in the current array that are not in the other array
public
differenceFrom(Arrayable|array<string|int, mixed> $arrayable) : Arrayable
Parameters
- $arrayable : Arrayable|array<string|int, mixed>
Return values
Arrayableeach()
Each through the array
public
each(callable $callback) : Arrayable
Parameters
- $callback : callable
Return values
Arrayablefilter()
Filter the array
public
filter([callable|null $callback = null ]) : Arrayable
Parameters
- $callback : callable|null = null
Return values
Arrayablefirst()
Get the first item in the array
public
first() : false|mixed
Return values
false|mixedflush()
Reset the array
public
flush() : $this
Return values
$thisflushMacros()
Remove all the macros we had registered
public
static flushMacros() : void
get()
Get an item from the array
public
get(string|null $name[, mixed|null $default = null ]) : mixed
If checkUpperAndLower is set to true, the method will check for uppercase and lowercase cases
Parameters
- $name : string|null
- $default : mixed|null = null
getA()
public
getA(string $key, string $className) : mixed
Parameters
- $key : string
- $className : string
Tags
getArray()
public
getArray(string $key) : array<string|int, mixed>|null
Parameters
- $key : string
Return values
array<string|int, mixed>|nullgetArrayable()
public
getArrayable(string $key) : Arrayable|null
Parameters
- $key : string
Return values
Arrayable|nullgetBool()
public
getBool(string $key) : bool|null
Parameters
- $key : string
Return values
bool|nullgetFloat()
public
getFloat(string $key) : float|null
Parameters
- $key : string
Return values
float|nullgetInt()
public
getInt(string $key) : int|null
Parameters
- $key : string
Return values
int|nullgetJson()
public
getJson(mixed $key) : false|string|null
Parameters
- $key : mixed
Tags
Return values
false|string|nullgetNegativeInteger()
public
getNegativeInteger(string $key) : int|null
Parameters
- $key : string
Return values
int|nullgetOrThrow()
public
getOrThrow(string $key[, Throwable|string|null $exception = null ]) : mixed
Parameters
- $key : string
- $exception : Throwable|string|null = null
Tags
getPositiveInteger()
public
getPositiveInteger(string $key) : int|null
Parameters
- $key : string
Return values
int|nullgetString()
public
getString(string $key) : string|null
Parameters
- $key : string
Return values
string|nullhas()
Check if the array has a key
public
has(string $key) : bool
Parameters
- $key : string
Return values
boolhasMacro()
Check if we have a method in the balonables
public
static hasMacro(string $name) : bool
Parameters
- $name : string
Return values
boolisAssoc()
Checks if an array is associative
public
isAssoc([array<string|int, mixed>|null $arr = null ]) : bool
Parameters
- $arr : array<string|int, mixed>|null = null
Return values
boolisEmpty()
Checks if the array is empty
public
isEmpty() : bool
Return values
boolisFilled()
public
isFilled() : bool
Return values
boolisMixed()
Checks if an array has both numeric and string keys
public
isMixed([array<string|int, mixed>|null $arr = null ]) : bool
Parameters
- $arr : array<string|int, mixed>|null = null
Return values
boolkeys()
Get the keys of the array
public
keys() : array<string|int, mixed>
Return values
array<string|int, mixed>keysToLowerCase()
Convert the keys of the array to lowercase
public
keysToLowerCase() : $this
Return values
$thiskeysToUpperCase()
Convert the keys of the array to uppercase
public
keysToUpperCase() : $this
Return values
$thislast()
Get the last item in the array
public
last() : false|mixed
Return values
false|mixedmacro()
Add a new mixable to the macros
public
static macro(string $key, $value) : void
Parameters
map()
Map through the array
public
map(callable $callback) : Arrayable
Parameters
- $callback : callable
Return values
ArrayablemapWithKeys()
Map through the array and flatten the result to a single array of values by using the callback
public
mapWithKeys(callable $callback) : Arrayable
Parameters
- $callback : callable
Tags
Return values
Arrayablemerge()
Merge a whole into the current array
public
merge(array<string|int, mixed>|Arrayable $array) : Arrayable
Parameters
- $array : array<string|int, mixed>|Arrayable
-
$array
Return values
Arrayablemixin()
Mix another object into the class.
public
static mixin(object $mixin[, bool $replace = true ]) : void
Parameters
- $mixin : object
- $replace : bool = true
Tags
only()
Get a subset of the items from the given array.
public
only([array<string|int, mixed>|string|null $keys = null ]) : Arrayable
Parameters
- $keys : array<string|int, mixed>|string|null = null
Return values
Arrayablepop()
public
pop() : mixed
reduce()
Reduce the array
public
reduce(callable $callback[, null $initial = null ]) : Arrayable
Parameters
- $callback : callable
- $initial : null = null
Return values
Arrayableremove()
Remove an item from the array
public
remove(string $key) : Arrayable
Parameters
- $key : string
Return values
Arrayablereplace()
public
replace(string $key[, mixed $value = null ]) : static
Parameters
- $key : string
- $value : mixed = null
Return values
staticreverse()
Reverse the array
public
reverse() : Arrayable
Return values
Arrayableset()
Set an item in the array by key and value
public
set(string $key, mixed $value) : $this
Parameters
- $key : string
- $value : mixed
Return values
$thisshift()
public
shift() : mixed
size()
Get the size of the array
public
size() : int
Return values
intslice()
Slice the array
public
slice(int $offset[, int|null $length = null ][, $preserve_keys = false ]) : $this
Parameters
Return values
$thissort()
Sort the array
public
sort(callable $callback) : Arrayable
Parameters
- $callback : callable
Return values
ArrayablesortKeys()
Sort the keys of the array
public
sortKeys(callable $callback) : Arrayable
Parameters
- $callback : callable
Return values
ArrayablesortValues()
Sort the values of the array
public
sortValues(callable $callback) : Arrayable
Parameters
- $callback : callable
Return values
ArrayabletoArray()
Convert the arrayable object to an array
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>toArrayable()
public
static toArrayable(array<string|int, mixed> $array) : Arrayable
Parameters
- $array : array<string|int, mixed>
Return values
ArrayabletoJson()
Convert the arrayable to json
public
toJson() : string
Return values
stringtype()
Return the type of the underlying array object
public
type() : string
Return values
stringunshift()
public
unshift(array<string|int, mixed> $value) : static
Parameters
- $value : array<string|int, mixed>
Return values
staticvalues()
Get the values of the array
public
values() : array<string|int, mixed>
Return values
array<string|int, mixed>valuesToLowerCase()
Convert the values of the array to lowercase
public
valuesToLowerCase() : Arrayable
Return values
Arrayablewhere()
Filter the array using the given callback.
public
where(callable $callback) : Arrayable
Parameters
- $callback : callable