geniusgeeek/pu-converter
Composer 安装命令:
composer require geniusgeeek/pu-converter
包简介
PU-converter is a simple and an easy to use PHP unit converter library for converting mathematical, engineering and scientific units
README 文档
README
PU-converter
PU-converter is an easy to use PHP unit converter library for converting S.I units to other compatible unit types. With PU-converter you can easily convert any engineering unit to its different unit types, for example, kilogram to grams, celsius to kelvin, e.t.c. Save your self the math stress and let the PU-converter library handle all conversions for you.
Coverage
PU-converter allows you to convert any unit to any other compatible unit type.
It has no external dependencies, simply include the library in your project and you're set
PU-converter can handle a wide range of unit types including:
- Length
- Area
- Volume
- Mass
- Speed
- Temperature
- Pressure
- Time
- Energy/Power
- Disk Storage
- Frequency
- Plane Angles
Installation
Using Composer
PU-converter can be insatlled using composer
composer require geniusgeeek/pu-converter
without composer
To utilize this class, first import puconverter.php into your project, and instantiate it.
include '/path/to/puconverter.php'; use unitConverter\puconverter\PUconverter;
Guidelines: How to use
- Create an object of the class for conversion
- The object propeties should be initialised on object creation
- Parameter 1 is the class for conversion, Parameter 2 is the value to be converted, Parameter 3 is the unit to convert, Parameter 4 is the unit to be converted to
- To return the conversion call the method convert()
- All units are to be passed in their SI units/abbreviations, example: kilogram is kg, seconds is s, e.t.c.
Documentation
Create an object for different conversion class using the syntax below
- $temperature => new PUconverter("temperature", $value, $fromUnit, $toUnit);
- Area => new PUconverter("area", $value, $fromUnit, $toUnit);
- Plane Angles => new PUconverter("angle", $value, $fromUnit, $toUnit);
- Time => new PUconverter("time", $value, $fromUnit, $toUnit);
- Volume => new PUconverter("volume", $value, $fromUnit, $toUnit);
- Speed => new PUconverter("speed", $value, $fromUnit, $toUnit);
- Length => new PUconverter("length", $value, $fromUnit, $toUnit);
- Pressure => new PUconverter("pressure", $value, $fromUnit, $toUnit);
- Mass => new PUconverter("mass", $value, $fromUnit, $toUnit);
- Frequency => new PUconverter("frequency", $value, $fromUnit, $toUnit);
- Energy/Power => new PUconverter("energy", $value, $fromUnit, $toUnit);
- Disk Storage => new PUconverter("storage", $value, $fromUnit, $toUnit);
Simple Examples
use unitConverter\puconverter\PUconverter; $length = new PUconverter("length", 3000, 'km', 'm'); echo $length->convert(); //this converts 3000 kilometers to its equivalent meter
//Returns 3000000 meters
use unitConverter\puconverter\PUconverter; $time = new PUconverter("time", 1, 'yr', 'week'); echo $time->convert(); // this converts 1 year to its equivalent time in weeks
//returns 52.143 weeks
Valid Units
Temperature
k => Kelvin
c => celsius
f => fahrenheit
Area
m2 => Square Meter
km2 => Square Kilometer
cm2 => Square Centimeter
mm2 => Square Millimeter
ft2 => Square Foot
mi2 => Square Mile
ac => Acre
ha => hectare
Volume
l => Litre
ml => Millilitre
m3 => Cubic Meter
gal => Gallon
oz => fluid ounces
ft3 => cubic feet
cm3 => cubic centi meter
Mass
kg => Kilogram
g => Gram
mg => Milligram
lb => Pound
t => Tonne
Speed
mps => Meters per Second
kph => Kilometers Per Hour
mph => Miles Per Hour
knots => Knots
Planes Angles
deg => Degrees
rad => Radian
grad => gradian
Pressure
pa => Pascal
kpa => kilopascal
mpa => MegaPascal
bar => Bar
mbar => Millibar
psi => Pound-force per square inch
Time
s => Second
yr => Year
month => Month
week => Week
day => Day
hr => Hour
min => Minute
ms => Millisecond
dec => decade
cen => century
Energy/Power
j => Joule
kj => Kilojoule
gcal => Gram calorie
whr => Watt Hour
kwhr => Kilowatt Hour
ev => Electronvolt
kcal => kilocalorie
Disk Storage
bit => bit
byte => byte
kb => kilobyte
mb => megabyte
gb => gigabyte
tb => terabyte
pb => petabyte
Frequency
hz => hertz
khz => kilo hertz
mhz => mega hertz
ghz => giga hertz
Length
m - Meter
km - Kilometer
cm - Centimeter
mm - Millimeter
um - Micrometer
nm - Nanometer
in - Inch
ft - Foot
yd - Yard
mi - Mile
Author
Initial work- Gracious Emmanuel
Contributors
Ordago: https://github.com/ordago
Contributing
Please, read the contributing.md to see contributing process, code of conduct and pull request process.
geniusgeeek/pu-converter 适用场景与选型建议
geniusgeeek/pu-converter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 07 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 geniusgeeek/pu-converter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 geniusgeeek/pu-converter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-05