hexcores / currency
Currency converter library
0.0.5
2020-04-28 06:01 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- mockery/mockery: 0.9.*@dev
- phpunit/phpunit: 4.3.*
README
Currency package is easy to use multiple currency value (format) at your application. (eg: E-Commerce)
Package Dependencies
- "php": ">=5.3.0"
Exchange Services
- (CentralBankMyanmarExchange) Excahange rate from Cental Bank of Myanmar API.
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