hexcores/currency

Currency converter library

0.0.5 2020-04-28 06:01 UTC

This package is auto-updated.

Last update: 2024-04-15 14:49:47 UTC


README

Currency package is easy to use multiple currency value (format) at your application. (eg: E-Commerce)

Build Status License

Package Dependencies

  • "php": ">=5.3.0"

Exchange Services

Formatter Services

  • BaseFormatter

Supported Currency Types

  • AUD (Australian dollar)
  • CNY (Chinese renminbi)
  • EUR (European Euro)
  • GBP (Pound Sterling)
  • JPY (Japanese yen)
  • MMK (Myanmar Kyats)
  • SGD (Singapore Dollar)
  • THB (Thai Baht)
  • USD (US Dollar)

Install

You can install currency package from composer

{
    "require": {
        "hexcores/currency": "dev-master"
    }
}

Usage

	use Hexcores\Currency\Type;
	use Hexcores\Currency\Converter;
	use Hexcores\Currency\Http\Client;
	use Hexcores\Currency\Formatter\BaseFormatter;
	use Hexcores\Currency\Exchange\CentralBankMyanmarExchange;

	$ex = new CentralBankMyanmarExchange(new Client());
	$f = new BaseFormatter();
	$converter = new Converter($ex, $f);

	echo "Convert : ". $converter->convert(2500, Type::USD, Type::MMK);
	echo "<br>Convert AUD: ". $converter->convert(2500, Type::USD, Type::AUD);

Use central bank exchange with factory

	use Hexcores\Currency\Type;
	use Hexcores\Currency\Factory;

	$converter = Factory::centralBank();

	echo "Convert : ". $converter->convert(2500, Type::USD, Type::MMK);
	echo "<br>Convert AUD: ". $converter->convert(2500, Type::USD, Type::AUD);

Example

You can run example.php file from example folder.

Testing

$ phpunit

Contributing

TODO