2017 © Pedro PelĂĄez
 

library currency-detector

Class to detect the currency from any string

image

mcuadros/currency-detector

Class to detect the currency from any string

  • Monday, August 28, 2017
  • by mcuadros
  • Repository
  • 4 Watchers
  • 15 Stars
  • 12,288 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 1 Versions
  • 4 % Grown

The README.md

CurrencyDetector Build Status

Class to detect the currency from any string, support +100 currencies., (*1)

Requirements

  • PHP 5.4.x

Installation

The recommended way to install CurrencyDetector is through composer. You can see the package information on Packagist., (*2)

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

Usage

getCurrency

Returns a string with the most common currency., (*3)

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

getCurrencies

Returns all the currencies suitable for this string., (*4)

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

getAmount

Return a money string as a float, (*5)

$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:, (*6)

$ phpunit --configuration phpunit.xml.dist

License

MIT, see LICENSE, (*7)

The Versions

28/08 2017

dev-master

9999999-dev

Class to detect the currency from any string

  Sources   Download

MIT

The Requires

  • php >=5.4.0