indibeast / currency-formatter
货币格式化工具
v1.0
2016-03-14 05:00 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ^6.1
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: ~0.6
This package is not auto-updated.
Last update: 2024-09-26 00:19:41 UTC
README
最低要求
- PHP 5.5+
安装
使用composer安装
composer require indibeast/currency-formatter
示例
$price = new Currency\Price(3000,'LKR'); $price->pretty();// Rs 3,000.00
您可以将选项作为数组传递到第三个参数。
$price = new Currency\Price(3000,'LKR',['show_decimal' => false,'seperator' => ',']); $price->pretty();// Rs 3,000
货币转换
$currency = new Price(1,'USD'); $currency->setConverter(new OpenExchangeConverter('app_id'));// Pass true as second parameter if you are having an enterprise APP_ID. $currency->convert('LKR') // This will convert U.S Dollars to Sri Lankan Rupees
如果您想实现自己的货币兑换提供者,请实现\Currency\Converter\ConverterInterface
class FixedConverter implements ConverterInterface{ /** * @return float */ public function getConversionRate($code,$to) { return 1; } }
许可证
MIT许可证(MIT)。请参阅许可证文件获取更多信息。