yosugi / functional-tools.php
PHP 简单功能工具
0.2.0
2020-05-21 16:43 UTC
Requires
- php: ^7.4
Requires (Dev)
- phpunit/phpunit: ^9.1
This package is auto-updated.
Last update: 2024-09-08 11:41:24 UTC
README
PHP 中的简单功能工具
用法
查看 tests/
安装
$ composer require yosugi/functional-tools.php
方法
数组
- get(string $key, ?array $argInputArray = null) //: callable|mixed
- set(string $key, $value, ?array $argInputArray = null) //: callable|array
- flatten(?array $argInputs = null) //: callable|array
- toPairs(?array $argInputs = null) //: callable|array
- fromPairs(?array $argInputs = null) //: callable|array
- keys(?array $argInputs = null) //: callable|array
- values(?array $argInputs = null) //: callable|array
- filter(callable $predicate, ?array $argInputs = null) //: callable|array
- map(callable $fn, ?array $argInputs = null) //: callable|array
- reduce(callable $fn, $initial, ?array $argInputs = null) //: callable|mixed
- head(?array $argInputs = null) //: callable|array
- rest(?array $argInputs = null) //: callable|array
- sortBy(callable $fn, ?array $argInputs = null) //: callable|array
集合
- filter(callable $predicate, ?iterable $argInputs = null) //: callable|array
- map(callable $fn, ?iterable $argInputs = null) //: callable|array
- reduce(callable $fn, $initial, ?iterable $argInputs = null) //: callable|mixed
- head(?iterable $argInputs = null) //: callable|array
- rest(?iterable $argInputs = null) //: callable|array
- sortBy(callable $fn, ?iterable $argInputs = null) //: callable|array
函数
- compose(callable ...$fns): callable
- pipe(callable ...$fns): callable
- partial(callable $fn, ...$args): callable
- curry(callable $fn, ...$args): callable
- tap(...$argInputs) //: mixed
字符串
- split(string $delimiter, ?string $argInput = null) //: callable|string
- join(string $glue, ?array $argInputs = null) //: callable|string
- replace($search, $replace, ?string $argInput = null) //: callable|string
- pregReplace($pattern, $replacement, ?string $argInput = null) //: callable|string
- trim(?string $argInput = null) //: callable|string