ben-gibson / bryn-fallback-calculator
An exchange rate calculator that defers calculation to its registered calculators in priority order until an exchange rate is successfully returned.
Installs: 20
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/ben-gibson/bryn-fallback-calculator
Requires
- php: ~7.0
- ben-gibson/bryn: ~0.0.1
Requires (Dev)
This package is not auto-updated.
Last update: 2025-10-12 01:59:49 UTC
README
A fallback calculator for Bryn that defers to registered calculators in priority order until an exchange rate is returned or they all fail.
Install
Use composer to install this library.
$ composer require ben-gibson/bryn-fallback-calculator
Usage
<?php require 'vendor/autoload.php'; $calculator = new \Gibbo\Bryn\Calculator\Fallback\FallbackCalculator(); $calculator->registerCalculator(Gibbo\Bryn\Calculator\Yahoo\YahooCalculator::default()); $calculator->registerCalculator(Gibbo\Bryn\Calculator\ECB\ECBCalculator::default()); $exchangeRate = $calculator->getRate( new \Gibbo\Bryn\Exchange( \Gibbo\Bryn\Currency::GBP(), \Gibbo\Bryn\Currency::USD() ) ); echo $exchangeRate; echo $exchangeRate->convert(550); echo $exchangeRate->flip()->convert(550); /** * OUTPUTS: * * 1 GBP(£) = 1.25 USD($) * 686.2295 * 440.814 */
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email ben.gibson.2011@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.