Releases: minwork/array
Allowed ArrayAccess in set method
Improved check method
Added new mode to check
method that enables checking if only one of the array elements meet specified condition.
Also greatly improved check
documentation - https://minwork.gitbook.io/array/validating-array/check
Added filter method
Added Arr::filter
method which is a wrapper around array_filter
to allow chaining in ArrObj
Added each method
Added method to traverse through array or iterable object without modifying it.
More info in documentation: https://minwork.gitbook.io/array/traversing-array/iterating
Added find method
Added method to find element(s) inside an array or iterable object.
More info in documentation: https://minwork.gitbook.io/array/manipulating-array/finding
Object oriented helper for convenient methods chaining
Added new class ArrObj
which can be used to easily chain Arr
methods.
ArrObj
instance can be obtained by either explicitly calling it's constructor with new ArrObj(...)
or for even easier chaining Arr::obj(...)
method.
Examples:
// Chain setting nested array values
Arr::obj()->set('foo', 'bar')->set('test.[]', 'test')->getArray() ->
[
'foo' => 'bar',
'test' => ['test']
]
// Quickly flatten array of objects grouped by id
Arr::obj([...])->groupObjects('getId')->flattenSingle()->getArray()
What's more, ArrObj
contain PHPDoc for every method that can be used in it, so you can take advantage of your editor autocomplete feature.
Full documentation of this feature, coming soon.
New map mode and 4 new utility methods
Added new Arr::map
mode (MAP_ARRAY_VALUE_KEY
) to resemble native array_map
but with array as first argument and callback as second.
Also added 4 new utility methods for getting first and last key or value from array:
getFirstKey
getLastKey
getFirstValue
getLastValue
v1.7.1
New common methods and aliases
has
New method
Check if (nested) element with specified keys exists in array
remove
New method
Remove (nested) element from array at path specified by keys
setNestedElement
Added alias set
getNestedElement
Added alias get
Added new method - pack
Pack
Inverse of unpack
method.
Unpack
Updated documentation regarding new modes.