Skip to content

Releases: minwork/array

Allowed ArrayAccess in set method

21 Apr 16:25
Compare
Choose a tag to compare

set method now also allow to supply object implementing ArrayAccess instead of pure array as first argument, as well as handling nested ArrayAccess objects.

Improved check method

24 Jan 16:16
Compare
Choose a tag to compare

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

22 Jan 15:14
Compare
Choose a tag to compare

Added Arr::filter method which is a wrapper around array_filter to allow chaining in ArrObj

Added each method

21 Jan 12:34
Compare
Choose a tag to compare

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

12 Jan 12:42
Compare
Choose a tag to compare

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

17 Sep 20:14
Compare
Choose a tag to compare

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

17 Sep 08:26
Compare
Choose a tag to compare

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

17 Jun 15:30
Compare
Choose a tag to compare

setNestedElement / set

  • Fixed error when passing empty $keys
  • Dropped cloning input array to preserve original object references in returned array

remove

  • Dropped cloning input to preserve original object references in returned array

New common methods and aliases

16 Jun 10:45
Compare
Choose a tag to compare

has

New method

Check if (nested) element with specified keys exists in array

Documentation

remove

New method

Remove (nested) element from array at path specified by keys

Documentation

setNestedElement

Added alias set

getNestedElement

Added alias get

Added new method - pack

13 Jun 10:22
Compare
Choose a tag to compare

Pack

Inverse of unpack method.

Unpack

Updated documentation regarding new modes.