blainesch/prettyarray

类似Ruby操作数组的工具。

1.0.5 2013-09-05 21:23 UTC

This package is not auto-updated.

Last update: 2024-09-24 05:31:24 UTC


README

PHP中处理数组的一种面向对象的方法。它尝试结合Ruby(枚举器/数组/哈希)方法和内置的PHP函数。

Build Status

示例1

<?php

use prettyArray\PrettyArray;

$arr = new PrettyArray(range(1,6));
$arr->group_by_(function($key, &$value) {
    return ($value % 3);
});
print_r($arr->to_a());
?>
Array
(
    [0] => Array
        (
            [0] => 3
            [1] => 6
        )

    [1] => Array
        (
            [0] => 1
            [1] => 4
        )

    [2] => Array
        (
            [0] => 2
            [1] => 5
        )
)

更多示例

更多示例可以在"/examples"目录中找到,格式为markdown,可在GitHub上查看。

安装

GIT

git clone git://github.com/BlaineSch/prettyArray.git
# OR
git submodule add git://github.com/BlaineSch/prettyArray.git

Composer

"require": {
    "blainesch/prettyarray": "1.0.0"
}
php compooser.phar install

要求

贡献

要求

测试

在提交任何pull请求之前,请确保您的方法通过了当前的单元测试。

cd PrettyArray && phpunit
PHPUnit 3.6.12 by Sebastian Bergmann.

Configuration read from /Users/blaineschmeisser/Sites/devup/PrettyArray/phpunit.xml

...............................................................  63 / 159 ( 39%)
............................................................... 126 / 159 ( 79%)
.................................

Time: 1 second, Memory: 10.00Mb

OK (159 tests, 180 assertions)

测试文件