Skip to content

Object oriented helper for convenient methods chaining

Compare
Choose a tag to compare
@minwork minwork released this 17 Sep 20:14
· 29 commits to master since this release

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.