olakunlevpn/bitcoin_ng 问题修复 & 功能扩展

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

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

olakunlevpn/bitcoin_ng

Composer 安装命令:

composer require olakunlevpn/bitcoin_ng

包简介

A lightweight bitcoin to Nigerian (NGN) converter and vice versa based on current exchange rates from your chosen provider: Coinbase, Coindesk, Bitpay and etc.

README 文档

README

Simple bitcoin converter from Nigerian (NGN) currency to bitcoin and also support USD to bitcoin conversion only.

Features

It is simple, lightweight, extensible, framework agnostic and fast.

  • You can convert Bitcoin to any currency Naira (NGN) and USD only

  • You can convert Nigerian (NGN) currency (ISO 4217 fiat or another cryptocurrency) to Bitcoin

  • It supports different exchange rates providers: Coinbase, Coindesk, Bitpay

  • It has baked-in caching (PSR16 compliant, swappable with your own or your framework's)

Install

Lets begin by installing the library by Composer:

$ composer require olakunlevpn/bitcoin_ng

Usage

You can then convert Bitcoin to any currency (ISO 4217 fiat or crypto) by:

use olakunlevpn\BitcoinNairaConverter\Converter;

$convert = new Converter;              // uses Coinbase as default provider
echo $convert->toCurrency('NGN', 0.5); // 2,250,50.00
echo $convert->toCurrency('LTC', 0.5); // 10.12345678

or you can use the helper function for convenience:

// uses Coinbase as default provider
echo to_currency('NGN', 0.5); // 2,250,50.00
echo to_currency('LTC', 0.5); // 10.12345678

You can also convert any currency (ISO 4217 fiat or crypto) to Bitcoin:

use olakunlevpn\BitcoinNairaConverter\Converter;

$convert = new Converter;         // uses Coinbase as default provider
echo $convert->toBtc(10000, 'NGN'); // 0.0036664
echo $convert->toBtc(20, 'LTC');  // 1.12345678

and it also has its helper function for convenience:

// uses Coinbase as default provider
echo to_btc(10000, 'NGN'); // 0.0036664
echo to_btc(20, 'LTC');  // 2.12345678

You can use different exchange rates from providers:

use olakunlevpn\BitcoinNairaConverter\Converter;
use olakunlevpn\BitcoinNairaConverter\Provider\CoinbaseProvider;
use olakunlevpn\BitcoinNairaConverter\Provider\CoindeskProvider;
use olakunlevpn\BitcoinNairaConverter\Provider\BitpayProvider;

$convert = new Converter(new CoinbaseProvider);
$convert = new Converter(new CoindeskProvider);
$convert = new Converter(new BitpayProvider);

or if you prefer to use the helper functions:

echo to_currency('NGN', 0.5, new CoindeskProvider); // 2,250,50.00
echo to_currency('LTC', 0.5, new BitpayProvider);   // 10.12345678
echo to_btc(10000, 'NGN', new CoindeskProvider);      // 0.00045678
echo to_btc(20, 'LTC', new BitpayProvider);         // 2.12345678

You can specify cache expire time (ttl) on provider by:

new CoinbaseProvider($httpClient, $psr16CacheImplementation, 5); // cache expires in 5mins, defaults to 60mins

Change log

Initial release

Testing

$ phpunit

Show full specs and features:

$ phpunit --testdox

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固