https://github.com/redco/redcode-currency-rate
Lib for loading currency rates
https://github.com/redco/redcode-currency-rate
Last synced: 2 months ago
JSON representation
Lib for loading currency rates
- Host: GitHub
- URL: https://github.com/redco/redcode-currency-rate
- Owner: redco
- Created: 2013-04-28T09:26:42.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2015-11-20T10:46:19.000Z (over 9 years ago)
- Last Synced: 2025-03-20T18:05:47.189Z (3 months ago)
- Language: PHP
- Size: 65.4 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# Currency Rates converter library [](https://packagist.org/packages/redcode/currency-rate) [](https://packagist.org/packages/redcode/currency-rate)
[](https://travis-ci.org/redco/redcode-currency-rate)
[](https://scrutinizer-ci.com/g/redco/redcode-currency-rate/?branch=master)
[](https://scrutinizer-ci.com/g/redco/redcode-currency-rate/?branch=master)
[](https://insight.sensiolabs.com/projects/b77d142f-47eb-4e30-81fb-ed56bff5e5bf)
[](https://www.versioneye.com/user/projects/5505aebb4a1064727700051d)This library shows an efficient way to work with currencies and currency rates form [Central Bank of Russia](http://www.cbr.ru/eng/), [European Central Bank](https://www.ecb.europa.eu), and [Yahoo Finance](https://finance.yahoo.com/currency-converter/). It contains base classes and interfaces which hide logic about loading currency rates, one of the most useful implementation is [Symfony2 bundle](https://github.com/redco/redcode-currency-rate-bundle).
## Installing
### Composer
You can easily install it with [composer](https://getcomposer.org) by command:
```
composer require redcode/currency-rate
```## Documentation
First of all you need to implement services [ICurrencyRateManager](https://github.com/redco/redcode-currency-rate-bundle/blob/master/Manager/CurrencyRateManager.php), [ICurrencyManager](https://github.com/redco/redcode-currency-rate-bundle/blob/master/Manager/CurrencyManager.php). Then DTO or Entity objects [Currency](https://github.com/redco/redcode-currency-rate-bundle/blob/master/Model/Currency.php) and [CurrencyRate](https://github.com/redco/redcode-currency-rate-bundle/blob/master/Model/CurrencyRate.php).
After that create and configure currencyConverter:
```php
use RedCode\Currency\Rate;// we have initialized $currencyRateManager and $currencyManager
$providerFactory = new Provider\ProviderFactory();
$providerFactory->addProvider(
new Provider\EcbCurrencyRateProvider`(
$currencyRateManager,
$currencyManager
)
);$converter = new CurrencyConverter(
$providerFactory,
$currencyRateManager,
$currencyManager
);$convertedValue = $converter->convert('USD', 'GBP', 100);
```## Tests
To run [tests](https://github.com/redco/redcode-currency-rate/tree/master/tests) use command below:
```shell
./tests/runTests.sh
```## Contribute
Pull requests are welcome. Please see our [CONTRIBUTING](https://github.com/redco/redcode-currency-rate/blob/master/CONTRIBUTING.md) guide.