montopolis / fda-nutrition-rounding-php
此包已被废弃,不再维护。未建议替代包。
根据FDA指南进行营养值舍入的库。
v1.0.4
2021-09-03 04:22 UTC
Requires (Dev)
- phpunit/phpunit: 4.0 - 9.5.9
README
根据FDA指南舍入营养信息的库基础库 (来源)
安装
您可以使用Composer将库添加到现有项目中
composer require montopolis/fda-nutrition-rounding-php
用法
<?php $rounder = new Montopolis\Fda\Rounding(); $rounder->calorie(123)->toInt(); // outputs 120 $rounder->calorie(123)->toFloat(); // outputs 120.0 $rounder->calorie(123)->toString(); // outputs "120 g" $rounder->carbohydrate(0.51)->toString(); // outputs "less than 1 g"
支持的养分类型
在撰写本文时,该库支持FDA指南中定义的所有养分类型 (指南)。
$rounder->alcohol($value)->toInt(); $rounder->betaCarotene($value)->toInt(); $rounder->calorie($value)->toInt(); $rounder->carbohydrate($value)->toInt(); $rounder->cholesterol($value)->toInt(); $rounder->dietaryFiber($value)->toInt(); $rounder->fat($value)->toInt(); $rounder->mineral($value)->toInt(); $rounder->otherFiber($value)->toInt(); $rounder->potassium($value)->toInt(); $rounder->protein($value)->toInt(); $rounder->sodium($value)->toInt(); $rounder->sugar($value)->toInt(); $rounder->vitamin($value)->toInt();
运行测试
./vendor/bin/phpunit PHPUnit 4.8.35 by Sebastian Bergmann and contributors. ......... Time: 100 ms, Memory: 4.00MB OK (9 tests, 46 assertions)
许可证
MIT许可证 (MIT)。请参阅 许可证文件 获取更多信息。