mcuadros/currency-detector

该软件包已被弃用,不再维护。未建议替代包。

用于从任何字符串检测货币的类

dev-master 2017-08-28 19:20 UTC

This package is not auto-updated.

Last update: 2020-05-01 16:46:08 UTC


README

从任何字符串检测货币的类,支持+100种货币。

要求

  • PHP 5.4.x

安装

推荐使用Composer安装CurrencyDetector。您可以在Packagist上查看软件包信息。

{
    "require": {
        "mcuadros/currency-detector": "dev-master"
    }
}

用法

getCurrency

返回最常见货币的字符串。

$detector = new Detector();
echo $detector->getCurrency('11.10$');
//Returns: USD

getCurrencies

返回适用于此字符串的所有货币。

$detector = new Detector();
echo $detector->getCurrencies('11.10$');
//Returns: ['USD', 'AUD', 'CAD', ...]

getAmount

以浮点数返回货币字符串。

$detector = new Detector();
echo $detector->getAmount('11,10.00$');
//Returns: 1110.00

测试

测试位于tests文件夹中。要运行测试,您需要PHPUnit。示例

$ phpunit --configuration phpunit.xml.dist

许可证

MIT,请参阅LICENSE