iiillexial/cryptocurrencies-money

https://github.com/moneyphp/money 的加密货币来源

0.0.1 2019-03-03 13:48 UTC

This package is not auto-updated.

Last update: 2024-09-24 18:25:48 UTC


README

此库提供加密货币列表和 CryptocurrencyFormatter

当前库仅支持 BTCLTCETH(我还没有找到好的加密货币列表来源)。如果您需要更多,请随意创建问题或PR。

安装

通过 Composer

$ composer require iillexial/cryptocurrencies-money

待办事项

  • 找到一个好的加密货币资源,同时也提供子单位。

  • 创建一个 CryptocurrencyMoneyParser

测试

通过以下方式运行单元测试:

$ composer test

用法

Money\Cryptocurrencies\Currencies\Cryptocurrenices 实现了 Money\Currencies 接口,因此您可以使用它,如原仓库中所述。

use Money\Cryptocurrencies\Currencies\Cryptocurrencies;
use Money\Currencies\AggregateCurrencies;
use Money\Currencies\ISOCurrencies;
use Money\Cryptocurrencies\Formatter\CryptocurrencyMoneyFormatter;

$currencies = new Cryptocurrencies();

// or

$currencies = new AggregatedCurrencies([
    new Cryptocurrencies(), new ISOCurrencies()
]);

$cryptocurrencyFormatter = new CryptocurrencyMoneyFormatter(2);
echo $cryptocurrencyFormatter->format(new Money(1 * 10**8, new Currency('BTC'))); // 1 BTC

许可证

MIT。请参阅 许可证文件 获取更多信息。