ilya / belt
为 PHP 开发者提供一系列工具。
2.1.1
2014-05-21 08:48 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpspec/phpspec: ~2
This package is not auto-updated.
Last update: 2024-09-14 15:46:12 UTC
README
为 PHP 开发者提供一系列工具。
版本 2.0.0 已发布。清晰的文档,改进的测试和代码质量。
安装
如果您想尝试它,请运行
php composer.phar require "ilya/belt:~2"
这将Belt作为Composer依赖项添加到您的项目中。
示例
Belt的点滴体验
use Belt\Belt; Belt::max([1, 2, 3]) // => 3 Belt::flatten([1, [2, [3]]]) // => [1, 2, 3] Belt::last([1, 2, 3], 2) // => [2, 3]
它提供的内容
- 60+ 个有用的函数,您可以在项目中使用。
- Belt经过全面测试。
- 源代码清晰并带有文档。
以下是您可获得的内容
boolean isDate(mixed $value)
boolean isNumber(mixed $value)
boolean isString(mixed $value)
boolean isFunction(mixed $value)
boolean isEmpty(mixed $value)
boolean isEqual(mixed $left, mixed $right)
boolean isBoolean(mixed $value)
boolean isObject(mixed $value)
boolean isArray(mixed $value)
boolean isTraversable(mixed $value)
boolean isNull(mixed $value)
boolean has(mixed $object, string $key)
array keys(mixed $object)
array values(mixed $object)
array methods(mixed $object)
mixed copy(mixed $value)
mixed extend(mixed $source, mixed $destination)
mixed apply(mixed $object, Closure $closure)
mixed defaults(mixed $object, array|mixed $defaults)
string escape(string $string)
string id(string $prefix = '')
mixed with(mixed $value)
void times(integer $number, Closure $closure)
mixed cache(Closure $closure)
mixed wrap(Closure $closure, Closure $wrapper)
mixed compose(array $closures, array $arguments = array())
void once(Closure $closure)
mixed after(integer $number, Closure $closure)
mixed|array first(array $elements, integer $amount = 1)
array initial(array $elements, integer $amount = 1)
array rest(array $elements, integer $index = 1)
mixed|array last(array $elements, integer $amount = 1)
array pack(array $elements)
array flatten(array $elements)
array range(integer $to, integer $from = 0, integer $step = 1)
array difference(array $one, array $another)
array unique(array $elements, Closure $iterator = null)
array without(array $elements, array $ignore)
array zip(array $one, array $another)
integer indexOf(array $elements, mixed $element)
array intersection(array $one, array $another)
array union(array $one, array $another)
void each(array $collection, Closure $iterator)
array map(array $collection, Closure $iterator)
array toArray(mixed $value)
integer|null size(array|Countable $value)
array shuffle(array $collection)
boolean any(array $collection, Closure $iterator)
boolean all(array $collection, Closure $iterator)
array reject(array $collection, Closure $iterator)
array pluck(array $collection, string $key)
boolean contains(array $collection, mixed $value)
array invoke(array $collection, string $function)
mixed reduce(array $collection, Closure $iterator, mixed $initial = 0)
array sortBy(array $collection, Closure $iterator)
array groupBy(array $collection, Closure $iterator)
mixed max(array $collection)
mixed min(array $collection)
开发
计划
- 添加
PHP 5.6
支持 - 利用 可变参数函数。
功能
- 集合 [完成]
- each [完成]
- map [完成]
- reduce [完成]
- max [完成]
- min [完成]
- size [待定]
- toArray [完成]
- groupBy [完成]
- sortBy [完成]
- shuffle [完成]
- all [完成]
- any [完成]
- pluck [完成]
- contains [完成]
- invoke [完成]
- reject [完成]
- 数组 [完成]
- 第一个 [已完成]
- 初始 [已完成]
- 剩余 [已完成]
- 最后一个 [已完成]
- 打包 [已完成]
- 展平 [已完成]
- 无 [已完成]
- 唯一 [已完成]
- 并集 [已完成]
- 差集 [已完成]
- 连接 [已完成]
- 交集 [已完成]
- 范围 [已完成]
- indexOf [已完成]
- 函数 [已完成]
- 缓存 [已完成]
- 单次 [已完成]
- 包装 [已完成]
- 之后 [已完成]
- 组合 [已完成]
- 对象 [已完成]
- 键 [已完成]
- 值 [已完成]
- 复制 [已完成]
- 扩展 [已完成]
- 默认 [已完成]
- 方法 [已完成]
- 应用 [已完成]
- 有 [已完成]
- 相等 [已完成]
- 空 [已完成]
- 是对象 [已完成]
- 是数组 [已完成]
- 是可遍历 [已完成]
- 是函数 [已完成]
- 是字符串 [已完成]
- 是数字 [已完成]
- 是布尔值 [已完成]
- 是日期 [已完成]
- 是空值 [已完成]
- 工具 [已完成]
- 使用 [已完成]
- 次数 [已完成]
- id [已完成]
- 转义 [已完成]
许可证
Belt 依照 MIT 许可证授权。