8000 GitHub - h4kuna/exchange at v7.0.4
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ČNB, ECB, RB exchange rates, fiat exchange, built-in cache, expandable for other banks, PSR-7, 17, 18

Notifications You must be signed in to change notification settings

h4kuna/exchange

Repository files navigation

Exchange

Latest stable Downloads this Month

Exchange is PHP script works with currencies. You can convert price, format add VAT or only render exchange rates.

Here is changelog.

Extension for framework

Installation via composer

$ composer require h4kuna/exchange

How to use

Init object Exchange by ExchangeFactory. Default Driver for read is Cnb, here are others.

For example define own exchange rates:

  • 25 CZK = 1 EUR
  • 20 CZK = 1 USD
use h4kuna\Exchange;

$exchangeFactory = new Exchange\ExchangeFactory('eur', 'usd', '/tmp/exchange', [
		'CZK',
		'USD',
		'eur', // lower case will be changed to upper case
	]);

$exchange = $exchangeFactory->create();

echo $exchange->change(100); // EUR -> USD = 125.0

// use only upper case
echo $exchange->change(100, 'CZK'); // CZK -> USD = 5.0
echo $exchange->change(100, NULL, 'CZK'); // EUR -> CZK = 2500.0
echo $exchange->change(100, 'USD', 'CZK'); // USD -> CZK = 2000.0

Change driver and date

Download history exchange rates. Make new instance of Exchange with history rate.

$exchange = $exchangeFactory->create(new \Datetime('2000-12-30'));

Access and iterator

/* @var $property Exchange\Currenry\Property */
$property = $exchange->getRatingList()['EUR'];
var_dump($property);


foreach ($exchange as $code => $property) {
    /* @var $property Exchange\Currenry\Property */
    var_dump($property);
}

About

ČNB, ECB, RB exchange rates, fiat exchange, built-in cache, expandable for other banks, PSR-7, 17, 18

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •  
0