Skip to content

Releases: minwork/array

Allowed ArrayAccess in set method

Choose a tag to compare

@minwork minwork released this 21 Apr 16:25

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

Choose a tag to compare

@minwork minwork released this 24 Jan 16:16

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

Choose a tag to compare

@minwork minwork released this 22 Jan 15:14

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

Added each method

Choose a tag to compare

@minwork minwork released this 21 Jan 12:34

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

Choose a tag to compare

@minwork minwork released this 12 Jan 12:42

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

Choose a tag to compare

@minwork minwork released this 17 Sep 20:14

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

Choose a tag to compare

@minwork minwork released this 17 Sep 08:26

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

Choose a tag to compare

@minwork minwork released this 17 Jun 15:30

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

Choose a tag to compare

@minwork minwork released this 16 Jun 10:45

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

Choose a tag to compare

@minwork minwork released this 13 Jun 10:22

Pack

Inverse of unpack method.

Unpack

Updated documentation regarding new modes.