https://github.com/thelia/currencyconverter
Advanced currency converter tools
https://github.com/thelia/currencyconverter
Last synced: 6 months ago
JSON representation
Advanced currency converter tools
- Host: GitHub
- URL: https://github.com/thelia/currencyconverter
- Owner: thelia
- License: lgpl-3.0
- Created: 2014-11-07T23:44:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-30T16:34:27.000Z (over 7 years ago)
- Last Synced: 2024-11-10T10:48:50.349Z (6 months ago)
- Language: PHP
- Homepage:
- Size: 28.3 KB
- Stars: 10
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Currency Converter
**Currency Converter** is a Library which helps you to convert a number from a currency to an another one.
The converter uses *provider* for converting the number. Each provider embed the logic for converting this number.[](https://travis-ci.org/thelia/CurrencyConverter) [](https://packagist.org/packages/thelia/currency-converter) [](https://scrutinizer-ci.com/g/thelia/CurrencyConverter/?branch=master)
## Installation
**Currency Converter** is still in development and doesn't have stable version for now.
Install **Currency Converter** through [Composer](http://getcomposer.org)
Create a composer.json file in your project with this content :
```
{
"require": {
"thelia/currency-converter": "~1.0"
}}
```## Usage
First, instantiate a ```Provider``` of your choice
```
$provider = new \Thelia\CurrencyConverter\Provider\ECBProvider();
```Then inject it in the ```CurrencyConverter```
```
$currencyConverty = new \Thelia\CurrencyConverter\CurrencyConverter($provider);
```Your ```CurrencyConverter``` is now ready to be used.
This library works with [ISO Code 4217](http://fr.wikipedia.org/wiki/ISO_4217) currency.
Example :```
$baseValue = new \Thelia\Math\Number('1');$convertedValue = $currencyConverter
->from('EUR')
->to('USD')
->convert($baseValue);
echo $baseValue->getNumber(); //1.24
```
## ProvidersA provider implements a simple interface and contains all the logic for converting a Number
from a Currency to an other one. Most of time a provider will use a webservice for getting
the exchange rate between two currencies.List of available providers :
| Provider | Description |
|---------:|-------------|
| [European Central Bank](http://www.ecb.europa.eu/stats/exchange/eurofxref/html/index.en.html) | All currencies quoted against the euro (base currency) |
| [My Currency](http://www.mycurrency.net) | Almost all currencies. |