wosiwo/alinq
Composer 安装命令:
composer require wosiwo/alinq
包简介
a implementation of linq to array
README 文档
README
a branche of the libarary Plinq(http://plinq.codeplex.com/license) which is a implementation of linq to array.
基于Plinq(http://plinq.codeplex.com/license) 修改的一个以linq方式操作数组的php类.
##The Purpose of Branche
This branche of the libaray trying to implemente the same feature without using SPL RecursiveArrayIterator;
这个分支试图在不依赖SPL RecursiveArrayIterator 这个标准库的情况下,实现与原Plinq同样的功能
##Differences
- This branche add a new method Instance to Instance the Alinq class without using "new" keyword.
Sometimes it's usefull,like the libaray live on a framework.
Here giving a example: 这个分支添加了一个新的方法:Instance,以传入的数组来实例化Alinq类,而不必使用new 关键字.
这在某些情况下还是有点用的,比如在框架代码中调用这个类的时候。
下面给出例子:
include('Alinq.php');
$alinq = new Alinq($array);
$otherAlinq = $alinq->Instance($newArray);
- Another difference is that some result of the this library are objects which could not used as array .
The result object should call it's ToArray method to get array result.
另外一个不同之处在与类库返回的结果,这个分支返回的对象结果不能直接作为数组使用,对象结果可以通过调用自身的ToArray方法来的到数组结果。 example:
include('Alinq.php'); $alinq = new Alinq($array); $result = $alinq->Select(function($k, $v){ return $v['int']; })->ToArray();
Alinq methods that will return object:
Instance()Single()GroupBy()Concat()SelectMany()Select()Where()Skip()Take()All()Any()Average()OrderBy()OrderByDescending()Max()Min()count()Distinct()Intersect()Diff()ElementAt()First()Last()Array2DInverse()ToArray()
Requirements
- PHP 5.3 or higher -- because of it depends on the new feature closures in PHP 5.3
Usage
include('Alinq.php'); $p = new Plinq($testArray); $result = $p->Where(function($k, $v){ return ($v['int'] > 998); })->ToArray();
##Running tests install phpunit
wget https://phar.phpunit.de/phpunit.phar chmod +x phpunit.phar sudo mv phpunit.phar /usr/local/bin/phpunit
run phpunit
phpunit --verbose test/AlinqTest.php
wosiwo/alinq 适用场景与选型建议
wosiwo/alinq 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 3, 最近一次更新时间为 2014 年 11 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 wosiwo/alinq 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wosiwo/alinq 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: New
- 更新时间: 2014-11-23