mcuadros / currency-detector
Class to detect the currency from any string
Installs: 26 311
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 3
Forks: 5
Open Issues: 0
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2020-05-01 16:46:08 UTC
README
Class to detect the currency from any string, support +100 currencies.
Requirements
- PHP 5.4.x
Installation
The recommended way to install CurrencyDetector is through composer. You can see the package information on Packagist.
{ "require": { "mcuadros/currency-detector": "dev-master" } }
Usage
getCurrency
Returns a string with the most common currency.
$detector = new Detector(); echo $detector->getCurrency('11.10$'); //Returns: USD
getCurrencies
Returns all the currencies suitable for this string.
$detector = new Detector(); echo $detector->getCurrencies('11.10$'); //Returns: ['USD', 'AUD', 'CAD', ...]
getAmount
Return a money string as a float
$detector = new Detector(); echo $detector->getAmount('11,10.00$'); //Returns: 1110.00
Tests
Tests are in the tests
folder.
To run them, you need PHPUnit.
Example:
$ phpunit --configuration phpunit.xml.dist
License
MIT, see LICENSE