codingmatters/unit-of-measures

不可变对象形式的测量单位

dev-develop 2020-04-21 16:27 UTC

This package is auto-updated.

Last update: 2024-09-22 02:28:14 UTC


README

一个用PHP编写的测量单位库。

安装

composer require codingmatters/unit-of-measures

质量单位

使用Weight::class来测量质量。以下是对重量对象的实际用法。

use CodingMatters\UoM\Weight;

$weightInGrams = Weight::inGrams(1000);
$weightInPounds = Weight::inPounds(250);
$weightInOunce = Weight::inOunch(350);

以克为单位的重量

use CodingMatters\UoM\Weight;

$weight = Weight::inGrams(1000); // will return string "1000 g"
$weight->unit(); // will return g
$weight->value(); // will return 1000

/**
 * Available conversion method:
 */
$weightInKilos = $weight->toKilo(); // will return string as "1 kg"
$weightInPounds = $weight->toPounds(); // will return string as ""

// you can still use the unit() and value() methods after conversion
$weightInKilos->unit(); // will return kg
$weightInKilos->value(); // will return 1

贡献者

Gab Amba开发,并由Coding Matters软件开发服务维护。

我们感谢所有贡献者,是他们使这个项目成为可能。

安全和漏洞

如果您在这个库中发现安全漏洞,请通过support@codingmatters.today发送电子邮件给Gab Amba。所有安全漏洞都将得到及时处理。

许可证

Copyright (C) 2020  Coding Matters Software Development Services

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://gnu.ac.cn/licenses/>.