Download the PHP package abgeo/nbg-currency without Composer
On this page you can find all versions of the php package abgeo/nbg-currency. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package nbg-currency
nbg-currency
PHP Library for getting data from National Bank of Georgia (NBG)'s API.
See documentation generated by phpDocumentor in docs/ folder.
Installation
You can install this library with Composer:
composer require abgeo/nbg-currency
Usage
Include composer autoloader in your main file (Ex.: index.php)
require_once __DIR__.'/../vendor/autoload.php';
Import Classes:
use ABGEO\NBG\Currency;
use ABGEO\NBG\Helper\CurrencyCodes;
Now you can create new Currency
Class object ex. for USD
currency:
$USD = new Currency(CurrencyCodes::USD);
The Currency
class constructor takes a single argument - the Currency Code.
You can pass it manually (ISO 4217) or using ABGEO\NBG\Helper\CurrencyCodes
class constants:
After creating a class object, we can get currency data.
The API gives us:
- Currency Amount;
- Currency Description;
- Currency Change value;
- Currency Change rate (-1 - decreased; 0 - unchanged; 1 - increased);
- Currency Date;
Public methods
getCurrency()
- Get Currency Amount;getDescription()
- Get Currency Description;getChange()
- Currency Change value;getRate()
- Get Currency Change rate;getDate()
- Get Currency Date;
Examples
Example for USD
Full example with USD and EUR
Export
You can use ABGEO\NBG\Exporter
Class for exporting currency data to CSV file or PHP Stream output.
ABGEO\NBG\Exporter
class has export()
method that takes 3 arguments:
- currencies - Single Currency Code or array;
- exportMode [Optional][Default: Exporter::EXPORT_2_FILE]
- Exporter::EXPORT_2_FILE(1) - To file;
- Exporter::Exporter::EXPORT_2_FILE(2) - To stream;
- file [Optional][Default: currency-{current-date}.csv] - Filename to export.
Export examples
Export single currency
Export many currencies
NOTE: Don't print anything before exporting to stream coz we use header()
function.
Authors
- Temuri Takalandze - Initial work - ABGEO
License
This project is licensed under the MIT License - see the LICENSE file for details