khanhicetea/twigeval
最新稳定版本:1.4.1
Composer 安装命令:
composer require khanhicetea/twigeval
包简介
Evaluate expression using Twig
README 文档
README
SAFE processing expression of variables from string without using eval (seems to be evil).
Core
Using twig template engine to produce the result, so you can use any twig syntax and its filters.
Usage
$ composer require khanhicetea/twigeval
/* $cacheDir could be : - false : no use cache (mean use eval function), be carefully ! - null : use sys_get_temp_dir() to get system temp directory as cache dir - string : cache directory path */ $cacheDir = null; $calculator = new KhanhIceTea\Twigeval\Calculator($cacheDir); $math = $calculator->number('a / 4 + b * 3', ['a' => 16, 'b' => 3]); // => 13 $boolean1 = $calculator->isTrue('(a and b) or c', ['a' => false, 'b' => true, 'c' => false]); // => false $boolean2 = $calculator->isFalse('(a and b) or c', ['a' => false, 'b' => true, 'c' => false]); // => true $string = $calculator->calculate('{{ a|reverse }} world !', ['a' => 'hello']); // => olleh world !
LICENSE
The MIT License (MIT) Copyright (c) 2018 KhanhIceTea
统计信息
- 总下载量: 3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-05