zweifisch/match
Composer 安装命令:
composer require zweifisch/match
包简介
pattern matching for php
关键字:
README 文档
README
pattern matching for php
install via composer
composer require 'zweifisch/match:*'
destruct value
$array = [1,[2,[3,4]]]; extract(\match\destruct(['a',['b',['c','d']]], $array)) or die("match failed"); echo "$a $b $c $d"; // "1 2 3 4"
passing to a function
$input = ['method'=>'foo', 'params'=>['bar']]; $pattern = ['method'=>'func', 'params'=>['arg1']]; $result = \match\let($pattern, $input, function($arg1, $func){ return "$func $arg1"; }); // "foo bar"
destruct multiple values
$input = ['method'=>'foo', 'params'=>['bar']]; $result = \match\let( ['method'=>'func', 'params'=>['arg1']], $input 'now', time(), function($func, $arg1, $now){ return "$func $arg1 $now"; } );
tests
composer install --dev vendor/bin/phpunit -c tests
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-06-22