加密技术/加密货币

无需使用数据库,在单个包中提供所有加密货币信息。

v0.2 2019-03-21 16:36 UTC

This package is auto-updated.

Last update: 2024-09-11 19:57:32 UTC


README

Latest Version on Packagist Total Downloads Build Status Last commit License Requires PHP7.1

无需使用数据库,在单个包中提供所有加密货币信息。

安装

$ composer require crypto-technology/cryptocurrency

用法

# See index.php for all examples

// Initialize new CryptocurrencyCollection()
$crypto_coll = new \CryptoTech\Cryptocurrency\CryptocurrencyCollection();
// Load the array with all cryptocurrencies enabled
$crypto_enabled = (include 'config/cryptocurrency.php')['crypto_enabled'];

// Inject the enabled cryptocurrencies' array in the collection
$crypto_coll->loadEnabledCrypto($crypto_enabled);

$cryptocurrency = new \CryptoTech\Cryptocurrency\Cryptocurrency();
$bitcoin = $cryptocurrency->load('Bitcoin');

// Return (int) cryptocurrency id (CoinMarketCap ID)
var_dump($bitcoin->getId());

// Return (string) cryptocurrency name
var_dump($bitcoin->getName());

// Return (string) cryptocurrency symbol
var_dump($bitcoin->getSymbol());

// Return (string) cryptocurrency type
// Can be 'coin' or 'token'
var_dump($bitcoin->getType());

// Return (string) cryptocurrency logo path with specified size
// Size can be '16', '32', '64', '128' or '200'
// Path must be the sub-path that allows you to get the correct logo path
// (sub-path must be point to the parent directory of crypto-logo directory)
var_dump($bitcoin->getLogo('128', '.'.DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR));

// Return (boolean) cryptocurrency mineable state
var_dump($bitcoin->isMineable());

// Return (string) cryptocurrency description
var_dump($bitcoin->getDescription());

// Return (array) cryptocurrency official project url
var_dump($bitcoin->getProjectUrl());

// Return (array) cryptocurrency explorer urls
// These urls can be used, for example, with sprintf($url, $wallet_address)
// because each url is returned in the format 'https://explorer/address/%s'
// where %s can be replaced with a wallet address for get information
// on that specific wallet address (the page response should be, in almost
// all cases, in json format)
var_dump($bitcoin->getExplorerUrl());

// Return (array) cryptocurrency sourcecode url
var_dump($bitcoin->getSourceCodeUrl());

更多信息请参阅CryptocurrencyInterface接口的PhpDocumentation。
Cryptocurrency类除了get方法外,还包含set方法(仅用于描述和项目,浏览器和源代码URL),允许您暂时覆盖默认值。

变更日志

请参阅变更日志以了解最近有哪些更改。

测试

# For Windows system
$ composer test-win

# For Unix system
$ composer test-unix

贡献

您的帮助总是受欢迎的!请随意提出问题、提问、讨论这个工具。
当然有一些贡献指南行为准则,我邀请您查看。
有关其他所有贡献,请见下文。

每次代码更改后,但在提交拉取请求之前,请应用Php Cs Fixer代码修复。

# For Windows system
$ composer php-cs-fixer-win

# For Unix system
$ composer php-cs-fixer-unix

安全

将使用Roave安全警报检查器检查CryptoTech\Cryptocurrency包的安全性漏洞。如果您发现任何安全问题,请通过电子邮件security@cryptotech.srl联系,而不是使用问题跟踪器。

代码

鸣谢

版本控制

我们使用SemVer进行版本控制。有关可用的版本,请参阅此存储库上的标签

许可证

GNU通用公共许可证版本3。请参阅许可证文件以获取更多信息。此作品许可根据GNU GPL v3