componenta/array
Composer 安装命令:
composer require componenta/array
包简介
Array helper functions for Componenta packages
README 文档
README
Standalone array helper functions for key checks, nested paths, filtering, mapping, sorting, grouping, recursive transforms, query-string building, and conversion to plain arrays.
Use this package when a library needs predictable array utilities without pulling in a larger collection component.
Installation
composer require componenta/array
Related Packages
| Package | Why it matters here |
|---|---|
componenta/arrayable |
to_array() consumes ArrayableInterface when an object exposes an array representation. |
componenta/config |
Often works with nested arrays and paths, while configuration access itself stays in componenta/config. |
Usage
use function Componenta\Array\array_get; use function Componenta\Array\array_path; use function Componenta\Array\array_set_path; $data = ['user' => ['name' => 'Ada']]; $name = array_path($data, 'user.name'); // "Ada" $missing = array_get($data, 'email', 'none'); // "none" array_set_path($data, 'user.email', 'ada@example.com');
Helper Groups
Lookup helpers:
array_hasarray_has_anyarray_has_allarray_missingarray_getarray_get_typedarray_get_or_failarray_patharray_path_or_fail
Mutation helpers:
array_putarray_addarray_setarray_set_patharray_forgetarray_forget_patharray_pull
Selection and transformation:
array_onlyarray_exceptarray_wherearray_map_with_keysarray_map_recursivearray_filter_nullarray_pluckarray_group_byarray_key_byarray_partition
Structure helpers:
array_flattenarray_collapsearray_dotarray_undotarray_dividearray_wraparray_chunk_by
Ordering and set-like helpers:
array_sortarray_sort_recursivearray_shufflearray_randomarray_unique_byarray_diff_assoc_recursivearray_merge_recursive_distinct
Predicate helpers:
array_containsarray_firstarray_lastarray_find_keyarray_everyarray_somearray_existsarray_is_associs_accessible
Other helpers:
array_joinarray_takearray_skiparray_queryto_array
Conversion
to_array() understands arrays, objects, iterators, iterator aggregates, and Componenta\Arrayable\Arrayable.
The package does not define serialization policy for domain objects. If an object has application-specific output rules, expose them through Arrayable or a serializer layer.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-14