php-etl / array-expression-language
此库实现了在ExpressionLanguage中操作数组数据的函数
v0.4.2
2023-10-02 15:19 UTC
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-09-24 16:08:04 UTC
README
本软件包扩展了ExpressionLanguage Symfony组件,以编译和评估带有自定义函数的数组和可迭代对象。
文档
安装
composer require php-etl/array-expression-language
使用
您可以在配置文件中使用以下示例中的这些表达式
foo: '@=count(input["myArray"])'
可用函数列表
通用函数
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
可与reduce一起使用的函数
join(string $separator) : callable
可与map一起使用的函数
extraxctData(string $path) : callable
可与arrayFilter一起使用的函数
任何函数都可以使用此方法,只要它返回true或false即可。