php-etl / array-expression-language
This library implements functions for manipulating array data in ExpressionLanguage
Installs: 3 424
Dependents: 0
Suggesters: 1
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=8.2
- symfony/expression-language: ^6.0
- symfony/property-access: ^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- infection/infection: ^0.26.18
- php-etl/pipeline-contracts: *
- php-etl/satellite: ^0.6.7
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
- rector/rector: ^0.15
This package is auto-updated.
Last update: 2024-10-24 16:17:29 UTC
README
This package extends the ExpressionLanguage Symfony component to compile and evaluate arrays and iterables with custom functions.
Documentation
Installation
composer require php-etl/array-expression-language
Usage
You can use these expressions in your configuration files as in the following example :
foo: '@=count(input["myArray"])'
List of available functions
Generic functions
firstKey(array $array) : int|string|null
lastKey(array $array) : int|string|null
keyExists(string|int $key, array $array) : bool
merge(array ...$arrays) : array
count(Countable|array $value) : int
combine(array $keys, array $values) : array
iterableToArray(Traversable $iterator, bool $use_keys = true) : array
map(callable $callback, iterable $source) : iterable
reduce(callable $callback, iterable $source) : string
list(int $length, mixed $value) : iterable
arrayFilter(array $array, ?callable $callback = null) : array
mapValues(array $input, iterable $values) : array
Functions that can be used with reduce
join(string $separator) : callable
Functions that can be used with map
extraxctData(string $path) : callable
Functions that can be used with arrayFilter
Any function can be used with this method as long as it returns true or false.