vasilevich/currencyconverter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vasilevich/currencyconverter

Composer 安装命令:

composer require vasilevich/currencyconverter

包简介

A simple currency converter purely converting currency without any additional overhead. is able to use Bank Of Israel, Bank Of Europe and Denmark as of now, as a base.

README 文档

README

Another simple self hosted currency converter based only on
free government data sources but any other data source can be added as-well.

has serialization/deserialization built in to allow you to save/cache the converters along with their last update timestamps,
thus avoiding unnecessary requests if you wish.

Installation

First, you will need to install Composer following the instructions on their site.

Then, simply run the following command:

composer require vasilevich/currencyconverter

Usage Example

<?php
require_once __DIR__ . "./vendor/autoload.php";

use vasilevich\currencyconverter\CurrencySourceBankOfEurope;
use vasilevich\currencyconverter\CurrencySourceBankOfIsrael;
use vasilevich\currencyconverter\CurrencySourceDenemarkNationalBank;
use vasilevich\currencyconverter\CurrencySourceFromSerialization;

$converter = new CurrencySourceBankOfEurope(); // use european bank
var_dump($converter->getCurrencyList()->convert("EUR", "USD", 1)); // -> 1 euro to usd through Europe bank
var_dump($converter->getCurrencyList()->convert("USD", "EUR", 1)); // -> 1 usd to euro through Europe bank
var_dump($converter->getCurrencyList()->convert("ILS", "EUR", 1)); // -> 1 ils to euro through Europe bank
var_dump($converter->getCurrencyList()->convert("EUR", "ILS", 1)); // -> 1 euro to ils through Europe bank
$converter = new CurrencySourceBankOfIsrael(); //use israeli bank
var_dump($converter->getCurrencyList()->convert("EUR", "USD", 1)); // -> 1 euro to usd through Israel Bank
var_dump($converter->getCurrencyList()->convert("USD", "EUR", 1)); // -> 1 usd to euro through Israel Bank
var_dump($converter->getCurrencyList()->convert("ILS", "EUR", 1)); // -> 1 ils to euro through Israel Bank
var_dump($converter->getCurrencyList()->convert("EUR", "ILS", 1)); // -> 1 euro to ils through Israel Bank

$converter = new CurrencySourceDenemarkNationalBank(); //use denemark national bank
var_dump($converter->getCurrencyList()->convert("EUR", "USD", 1)); // -> 1 euro to usd through Denemark national Bank
var_dump($converter->getCurrencyList()->convert("USD", "EUR", 1)); // -> 1 usd to euro through Denemark national Bank
var_dump($converter->getCurrencyList()->convert("ILS", "EUR", 1)); // -> 1 ils to euro through Denemark national Bank
var_dump($converter->getCurrencyList()->convert("EUR", "ILS", 1)); // -> 1 euro to ils through Denemark national Bank

$serializedConverter = $converter->serialize(); // convert the object to string, ready for caching/saving/transferring by your own logic
$unserializedConverter = new CurrencySourceFromSerialization($serializedConverter); //obtain the serialized converter from anywhere and deserialize the converter back into use
var_dump($unserializedConverter->getCurrencyList()->convert("ILS", "USD", 4));  //test converter

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固