Convenient and safe way to work with collections.
...And it's been (more or less) solved by some other libraries, like nikic/iter, doctrine/collections or even php-ds/php-ds. That's why the current version of the library contains just a few helpers for that libraries, to conveniently integrate them together.
composer require alexeyshockov/colada:~3.0
The library's functions are split by namespaces, one namespace = specific function a dependency (in most cases).
Helpers from this namespace require php-ds/php-ds to be available.
group_by()
function prodices a two dimension array (\ArrayObject
or \Ds\Map
, depends on the group key type), from
an iterable based on a group function.
TODO
Helpers from this namespace require guzzlehttp/promises or react/promise to be available.
This is the same concept applied to two most popular libs with async capabilities. If you are familiar with async/await in C# or node.js or coroutines in Go, this should be simple. Take a look at the script, written in callback-style and in coroutine-style:
TODO
TODO
Helpers from this namespace require phpoption/phpoption to be available.
Simple helpers for general iterable
types.
uasort()
and uksort()
are basically equivalents for the internal ones, but work for arbitrary iterable
type.
To run all the tests, install the vendors (with Composer) and execute:
vendor/bin/phpunit --testdox
All classes or functions that are intended to be used by a user should be marked with @api
PHPDoc tag. Anything without this mark
are internal and should not be used by the end user (no guarantees that the interface will stay the same between
versions).