wernerdweight/ra 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wernerdweight/ra

最新稳定版本:2.0.2

Composer 安装命令:

composer require wernerdweight/ra

包简介

PHP Array object with consistent and predictable API

README 文档

README

PHP Array object with consistent, predictable and convenient API

Build Status Latest Stable Version Total Downloads License

Instalation

  1. Download using composer
composer require wernerdweight/ra
  1. Use in your project
use WernerDweight\RA\RA;
 
// helper methods (extracted here to simplify the code below and emphasize the difference)

function filterFunction(string $god): bool {
    return false !== strpos($god, 's');
}
 
function mapFunction(string $godContainingTheLetterS): string {
    return strtoupper($godContainingTheLetterS);
}
 
function reduceFunction(string $carry, string $god): string {
    return $carry .= ($carry[-1] === ' ' ? '' : ', ') . $god;
}
 
// create new RA
$egyptianGods = new RA(['Ra', 'Osiris', 'Anubis', 'Horus']);
 
// use as object
$godsContainingTheLetterSInUppercase = $egyptianGods
    ->filter('filterFunction')
    ->map('mapFunction')
    ->reverse()
    ->reduce('reduceFunction', 'My favourite Egyptian Gods are ');
 
echo $godsContainingTheLetterSInUppercase . "\n";
 
// use as normal array
$godsContainingTheLetterSInUppercase = array_reduce(
    array_reverse(
        array_map(
            'mapFunction',
            array_filter(
                $egyptianGods->toArray(),
                'filterFunction'
            )
        )
    ),
    'reduceFunction',
    'My favourite Egyptian Gods are '
);
 
echo $godsContainingTheLetterSInUppercase . "\n";
 
// RA extends Iterator, ArrayAccess and Countable
foreach ($egyptianGods as $god) {
    echo sprintf("My favourite Egyptian God is %s\n", $god);
}

API

TODO:

统计信息

  • 总下载量: 9.04k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 8
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-17