gufy/currency

Currency API (currently OpenExchangeRate) Wrapper for PHP

v1.0.0 2016-06-10 08:58 UTC

This package is auto-updated.

Last update: 2024-04-13 17:13:27 UTC


README

Build Status Coverage Status

Table of contents

Installation

Just run this simple command through your command line

composer require gufy/currency:~1

Or update manually your composer.json

{
  "require":{
    ...
    "gufy/currency":"~1"
    ...
  }
}

Usage

This package currently only support OpenExchangeRates as the main API.

Getting latest currency rates

<?php
include 'vendor/autoload.php';

use Gufy\Currency\OpenExchange;

$api = new OpenExchange("your-app-id");
$rates = $api->rates();

Getting currency rates based on date

<?php
include 'vendor/autoload.php';

use Gufy\Currency\OpenExchange;
$date = "2016-06-06";
$api = new OpenExchange("your-app-id");
$rates = $api->rates("USD", $date);

Convert value to some currency

<?php
include 'vendor/autoload.php';

use Gufy\Currency\OpenExchange;
$api = new OpenExchange("your-app-id");
$value = 10;
$base = "USD";
$target = "IDR";
$rates = $api->convert($value, $base, $target);

Get all available currencies

<?php
include 'vendor/autoload.php';

use Gufy\Currency\OpenExchange;

$api = new OpenExchange("your-app-id");
$rates = $api->currencies();