/currency-amount-converter

A simple Laravel package that converts amount to other currency value 💱

Primary LanguagePHPMIT LicenseMIT

A simple package that converts amount to other currency value.

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Installation

You can install the package via composer:

composer require currency-amount-converter/currency-amount-converter

You can publish the config file with:

php artisan vendor:publish --tag="currency-amount-converter-config"

Usage

You can use method chaining:

use Currency\CurrencyConverter\CurrencyConverter;

$currency = new CurrencyConverter();
$currency->convert(1)->value();        // 59.05

$currency = new CurrencyConverter();
$currency->convert(1, 'PHP')->value(); // 59.05

$currency = new CurrencyConverter();
$currency->convert(1, 'BGN')->value(); // 1.9558

$currency = new CurrencyConverter();
$currency->convert(2, 'BGN')->value(); // 3.9116

or through the exposed API request that returns a JSON response.

GET /api/v1/currency-converter?amount=2&currency=USD
{
    "success" => 1,
    "data" => [
      "rate" => 2.175
    ]
}

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.