bnet/bnmoney

处理货币和货币的PHP库

1.3.4 2017-07-20 14:16 UTC

This package is auto-updated.

Last update: 2024-09-26 16:29:05 UTC


README

PHP 5.6+ 库,使处理货币更安全、更简单、更有趣!

这是 Mathias Verraes 的 Money Library 的分支,扩展了

  • 添加 CurrencyLookup,以支持不同的货币来源(包括json文件示例)
  • 扩展了货币列表和设置(小数点、子单位系数、符号、iso代码等),来自优秀的 RubyMoney(ISO 4217)
  • 添加格式化方法以格式化 Money 字符串
<?php

use Money\Money;

$fiveEur = Money::EUR(500);
$tenEur = $fiveEur->add($fiveEur);

list($part1, $part2, $part3) = $tenEur->allocate(array(1, 1, 1));
assert($part1->equals(Money::EUR(334)));
assert($part2->equals(Money::EUR(333)));
assert($part3->equals(Money::EUR(333)));

分叉前的文档可在 http://money.readthedocs.org 查找

安装

使用 composer 安装库。将以下内容添加到您的 composer.json

{
    "require": {
        "bnnet/bnmoney": "~1.0"
    }
}

现在运行 install 命令。

$ composer.phar install

集成

有关 MoneyBundle 的信息,请参阅 Symfony集成(仅在分叉之前)。