General information

Object creating

You can create ArrObj by calling
1
new ArrObj(array|ArrayAccess $array = [])
2
3
// Or for easier chaining
4
Arr::obj(array|ArrayAccess $array = [])
Copied!

Chaining

For chaining just call standard Arr methods without first parameter (array or ArrayAccess object).
As a convenience ArrObj contains PHPDoc definitions for every available method, so you don't need to guess their parameters.
Also you can quickly jump to the corresponding Arr method by using @see tag.
To obtain array from object just call getArray() as the final method in chain.

Examples

1
// Chain setting nested array values
2
Arr::obj()->set('foo', 'bar')->set('test.[]', 'test')->getArray() ->
3
[
4
'foo' => 'bar',
5
'test' => ['test']
6
]
7
8
// Quickly flatten array of objects grouped by id
9
Arr::obj([...])->groupObjects('getId')->flattenSingle()->getArray()
Copied!
Last modified 1yr ago