redcode / currency-rate
Useful library for fetching currency rates from cbr and ecb providers
Installs: 264 100
Dependents: 3
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 3
Open Issues: 2
Requires
- php: >=5.4.0
Requires (Dev)
- fabpot/php-cs-fixer: ~1.5
- phpunit/phpunit: ~4.5
- satooshi/php-coveralls: ~0.6
This package is not auto-updated.
Last update: 2024-10-26 14:35:49 UTC
README
This library shows an efficient way to work with currencies and currency rates form Central Bank of Russia, European Central Bank, and Yahoo Finance. It contains base classes and interfaces which hide logic about loading currency rates, one of the most useful implementation is Symfony2 bundle.
Installing
Composer
You can easily install it with composer by command:
composer require redcode/currency-rate
Documentation
First of all you need to implement services ICurrencyRateManager, ICurrencyManager. Then DTO or Entity objects Currency and CurrencyRate.
After that create and configure currencyConverter:
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 use command below:
./tests/runTests.sh
Contribute
Pull requests are welcome. Please see our CONTRIBUTING guide.