vbpupil/measurement-converter
Composer 安装命令:
composer require vbpupil/measurement-converter
包简介
A simple but effective measurement converter which allows you to quickly create measurement objects that can be easily converted into other measurement formats, for example converting an Imperial measurement into Metric.
README 文档
README
Measurement Converter
A simple but effective measurement converter which allows you to quickly create measurement objects that can be easily converted into other measurement formats, for example converting an Imperial measurement into Metric.
Currently this package supports the following:
- Metric Linears
- Imperial Linears
- Metric Cubic
- Imperial Cubic
- Weights Conversion
- Tonne
- US Ton
- Imperial Ton
By creating a linear measurement unit object you immediately inherit the values of that conversion to your units counterparts. For example, by creating a 1 Inch Object you also have access to the Feet, Yard & Mile measurements off the bat
Supported Units
| Type | Unit | Identified |
|---|---|---|
| Linear Metric | ||
| Millemeter | mm | |
| Centimeter | cm | |
| Meter | m | |
| Kilometer | km | |
| Linear Imperial | ||
| Inch | in | |
| Feet | ft | |
| Yard | yd | |
| Mile | ml | |
| Weight | ||
| Tonne | ||
| US Ton | ||
| Imperial Ton |
Usage Examples
Metric Example
1. create a 50 foot object
$feet= LinearUnitBuilder::build(new FloatType(18), new StringType('ft')); dump($feet->getHumanReadableLong());
2. convert that into millimeters
$converter = new LinearUnitsConverter($feet, new StringType('mm'));
3. get the new millimeters object
$mm = $converter->get(); dump($mm->getHumanReadableLong());
4. convert millemeters into inches & get the inches object
$converter = new LinearUnitsConverter($mm, new StringType('in')); $inch = $converter->get(); dump($inch->getHumanReadableLong());
Cubic Example
1. create a width, depth & height object and pass these into the cubic constructor
$width = LinearUnitBuilder::build(new FloatType(18), new StringType('m')); $depth = LinearUnitBuilder::build(new FloatType(42), new StringType('m')); $height = LinearUnitBuilder::build(new FloatType(3), new StringType('cm')); $cubic = new CubicUnit($width, $depth, $height); dump($cubic->getValue(new StringType('mm')));
Weight Example
1. to convert the cubic measurement into a weight simply pass in the SUPPORTED matrial name & cubic object
$tonnage = new WeightTonnageDensityConverter('soil', $cubic); dump($cubic); dump($tonnage->getValue());
2. you can also supply your own density measurement, which will be added to the density array as custom
$tonnage = new WeightTonnageDensityConverter(1.2, $cubic); dump($cubic); dump($tonnage->getValue());
Simple Conversion Example
1. start by creating a simple 20 foot Imperial LinearUnit object
$length = LinearUnitBuilder::build(new FloatType(20), new StringType('ft'));
2. then convert this into a cm Metric LinearUnit object
$length = LinearUnitBuilder::build( new FloatType((new Conversion($l))->into( new StringType('cm') )), new StringType( 'cm' ));
Supported Materials & Densities
| Material | Density, kg/m3 |
|---|---|
| acetone | 795 |
| acetylene | 1.1709 |
| air | 1.928 |
| alcohol | 789 |
| ammonia | 0.7714 |
| antifreeze | 1112 |
| argon | 1.7839 |
| asphalt | 1100 |
| azote | 1.251 |
| beer | 1041 |
| brass | 8500 |
| bronze | 8600 |
| butter | 920 |
| cadmium | 8640 |
| caprolon | 1150 |
| carbon_monoxide | 1.25 |
| cast_iron | 7300 |
| cement | 2900 |
| chlorine_oxide | 3.89 |
| chlorine | 3.22 |
| clay | 1750 |
| concrete | 2400 |
| concrete_solution | 2100 |
| copper | 8900 |
| crushed_stone | 1350 |
| diesel | 860 |
| dioxide_of_chlorine | 3.09 |
| ethane | 1356 |
| ether | 740 |
| fiberglass | 1900 |
| fluorine | 1695 |
| fluoroplast | 1400 |
| garbage | 250 |
| gasoline | 750 |
| glass | 2500 |
| glycerin | 1260 |
| gold | 19300 |
| gravel | 1550 |
| ground | 1800 |
| helium | 0.1785 |
| hydrogen | 0.08987 |
| ice | 917 |
| indium | 7300 |
| kerosene | 810 |
| krypton | 3.74 |
| lead | 11400 |
| liquid_hydrogen | 70 |
| mercury | 13600 |
| methane | 0.6682 |
| methyl_alcohol | 810 |
| milk | 1030 |
| neon | 0.8999 |
| nitrous_oxide | 1978 |
| nitrogen | 1251 |
| nitrogen_fluoride | 2.9 |
| nitric_oxide | 1.3402 |
| oil | 850 |
| olive_oil | 920 |
| oxygen | 1.429 |
| ozone | 2.22 |
| paint | 1300 |
| paladius | 12160 |
| paper | 950 |
| petrol | 750 |
| phosphorous_fluoride | 3907 |
| platinum | 21450 |
| polyamide | 1150 |
| polycarbonate | 1200 |
| polyethylene | 960 |
| polypropylene | 900 |
| polystyrene | 1050 |
| polyvinyl_chloride | 1400 |
| porcelain | 2300 |
| propane | 1.864 |
| radon | 9.73 |
| rubber | 1050 |
| sand | 1800 |
| sea_water | 1025 |
| silver | 11500 |
| slag | 3550 |
| snow | 200 |
| soil | 1800 |
| steel | 7800 |
| stone | 2200 |
| sunflower oil | 915 |
| sulfuric_acid | 1840 |
| tin | 7300 |
| trimethylamine | 2.58 |
| tungsten | 19300 |
| viniplast | 1450 |
| water | 1000 |
| wood_birch | 650 |
| wood_bud | 690 |
| wood_cork | 480 |
| wood_larch | 660 |
| wood_linden | 530 |
| wood_pine | 520 |
| wood_spruce | 450 |
| xenon | 5.89 |
| zinc | 7130 |
vbpupil/measurement-converter 适用场景与选型建议
vbpupil/measurement-converter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 184 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 09 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 vbpupil/measurement-converter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vbpupil/measurement-converter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 184
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-12