定制 wemash/hooray 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

wemash/hooray

最新稳定版本:0.85.4

Composer 安装命令:

composer require wemash/hooray

包简介

Fall in love with arrays all over again

README 文档

README

In the long, long ago there were just arrays, and functions to handle them. That was cool, but the functions were scattered all over the floor and their argument orders weren't all that orderly. Then @sancho had a great idea! Take the functions, order their arguments a little better, and make them chainable.

Wrap, transform, realize

Hooray is all about giving you the tools you need to work on arrays, in the form of transformations. The transformations are hung off a Hooray object, which you wrap around your array. When you are all done, just get your new array out the other end. Here is an example:

$> hooray([1, 2, 3])
   ->map(function(thing) { return thing + 1; })
   ->realize();
$> [2, 3 4]

Hooray accepts arrays, or just a list of arguments if that's all you've got, so put those brackets away:

$> hooray(1, 2, 3)
   ->realize();
$> [1, 2, 3]

Hooray also accepts other hooray objects, so don't worry about double wrapping:

$> hooray(hooray(1, 2, 3))
   ->realize();
$> [1, 2, 3]

Adding links to the chain

So, let's say you've been working with hooray, and so far it has solved all your problems. Now you come across a problem that would totally be solved if you could Just. Invoke. A. Transform! Well, sure, you can do that:

$> Chain::add(
     "reticulateTheSplines",
     function($data, $arg1, $arg2) {
        // Reticulate some splines right here...
        return ["RE", "TIC", "ULATED"];
     });
$> hooray(1, 2, 3)
   ->reticulateTheSplines($arg1, $arg2)
   ->realize();
$> ["RE", "TIC", "ULATED"]

As you can see, a call to Chain::add created a new link that can immediately be invoked from any instance of hooray. What's more, that link can accept arguments, and the actual array hooray is wrapping gets prepended to the argument list before invocation. The link is then free to return whatevs. It's expected that transformations added through Chain::add return an array though. If you want to return something other than an array, use Chain::addTerminal.

Using the library

  1. git clone https://github.com/wemash/hooray
  2. phing package
  3. cp hooray.phar /var/www/wherever/you/want

or.....

  1. composer require wemash/hooray
  2. composer update
  3. composer install

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2015-04-01