bonu / iterable
Handy utilities for iterables
Installs: 142
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/bonu/iterable
Requires
- php: ^8.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.88
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
- rector/rector: ^2.2
This package is auto-updated.
Last update: 2025-11-24 06:37:09 UTC
README
Handy utility methods that simplify iterable operations.
Requirements
- Minimum version of PHP 8.2
Installation
composer require bonu/iterable
Usage
use Bonu\Iterable\Iterables; // ['FOO', 'BAR'] Iterables::map( ['foo', 'bar'], static fn (string $value): string => mb_strtoupper($value), ); // ['FOO' => 'foo', 'BAR' => 'bar'] Iterables::mapWithKeys( ['foo', 'bar'], static fn (string $value): array => [ mb_strtoupper($value) => $value, ], ); // 'foo' Iterables::first(['foo', 'bar']); // false Iterables::isEmpty(['foo', 'bar']); // true Iterables::isNotEmpty(['foo', 'bar']); // ['foo', 'bar'] Iterables::keys(['foo' => 'bar', 'bar' => 'baz']); // [[1, 2], [3]] Iterables::chunk([1, 2, 3], 2);
License
This package is licensed under the MIT License.