定制 marzzelo/uconverter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

marzzelo/uconverter

最新稳定版本:1.0.5

Composer 安装命令:

composer require marzzelo/uconverter

包简介

Customizable Physical Unit Converter - Demo library - Please do not use it in production

README 文档

README

uconverter is a customizable units converter.

Install

composer require marzzelo/uconverter

Usage

Instanciating a new units-converter:

$converter = new UnitsConverter([
		    'gf'  => 1000.0,
		    'N'   => 9.8066,
		    ...
		]);

(All quantities must be equivalent, ie.: 1000 gf == 9.8066 N).

Example: decaNewtons to kilograms:

print $converter->kgf(1, 'daN');  // 1.019721

Adding a new unit after construction:

$converter->lbf = 2.2046;

$converter->kgf(2.2046, 'klbf');  // 1000

multiples & submultiples

Included prefixes:

                'da' => 10,
                'a'  => 1e-18,
                'f'  => 1e-15,
                'p'  => 1e-12,
                'n'  => 1e-9,
                'u'  => 1e-6,
                'm'  => 1e-3,
                'c'  => 0.01,
                'd'  => 0.1,
                'h'  => 100,
                'k'  => 1000,
                'M'  => 1e6,
                'G'  => 1e9,
                'T'  => 1e12,
                'P'  => 1e15,
                'E'  => 1e18,

Example (TeraNewtons to microNewtons):

$converter->uN(1.0, 'TN');  //  1.0e+18

Using Included Converters

To use included converters, use the static UnitsConverter::getConverter(<name>).
'force', 'length' and 'pressure' converters are included.

$fconverter = UnitsConverter::getConverter('force');
$pconverter = UnitsConverter::getConverter('pressure');
$lconverter = UnitsConverter::getConverter('length');

print $fconverter->N(1, 'kgf');     // 9.806652048217
print $pconverter->Pa(1, 'MPa');    // 1e6
print $lconverter->cm(1, 'in');     // 2.5400000025908

Available built-in units

Force

N, lbf, gf, ouncef, poundf, dyne, sthene

and their multiples:

daN, kN, klbf, kgf, kpoundf, etc.

Pressure

psi, Pa, gmm2, bar, atm, mHg, inHg, inH2O, torr

and their multiples:

kPa, hPa, MPa, kgmm2, cmHg, mmHg, mbar, etc.

Length

m, in, ft, hand, ly, mi, yd, pc, AU, Ao

and their multiples:

dm, cm, mm, um, dam, hm, km, ...

统计信息

  • 总下载量: 75
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-26