sysvyz/hurl 问题修复 & 功能扩展

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

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

sysvyz/hurl

Composer 安装命令:

composer require sysvyz/hurl

包简介

PHP7 language wrapper

README 文档

README

Hurl is a data transformation framework, designed to compose complex transformations.

Installation

You will need composer require sysvyz/hurl

Usage

Hurl is designed to build algorithms as datastructures. Each algorithm is represented by a tree. A tree is represented by its root node. Trees should be stateless (and immutable) in order to reuse them. A Node represents a data transformation.

Creating Nodes

A Node is basically wrapper for functions or Closures if you like. Like functions Nodes have inputs(parameters) and a output.

$fromHex = Node::call(function ($data) {
    return hexdec($data);
});
var_dump($fromHex('a'));
        
//int(10)

Build-in transformations

Nodes are transformation rules. There are several build-in php functions wrapped as Node

$explode = Node::explode('.');
var_dump($explode('a.b'));
//array(2) {
//  [0]=>
//  string(1) "a"
//  [1]=>
//  string(1) "b"
//}

Chained transformations

Nodes can be chained to perform multiple consecutive transformations

$chain = $explode->implode('-');
var_dump($chain('a.b'));
//string(3) "a-b"

Map

One of the most common transformation is array_map. Node provides a convenient way of performing those operations. Since the callback function of array_map is nothing else than a transformation, it's obvious to use Nodes as callbacks.

$map = $explode->map($fromHex)->implode('.');
var_dump($map('a.b'));
//string(5) "10.11"

Sort

$sort = Node::ARRAY()->sort(function ($a,$b){
    return $a-$b;
});
var_dump($sort([2,5,3,4,1]));
//array(5) {
//  [0]=>
//  int(1)
//  [1]=>
//  int(2)
//  [2]=>
//  int(3)
//  [3]=>
//  int(4)
//  [4]=>
//  int(5)
//}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固