crypto-technology/cryptocurrency

All cryptocurrencies infos in a single package without using a database.

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

This package is auto-updated.

Last update: 2024-12-11 20:29:11 UTC


README

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

All cryptocurrencies infos in a single package without using a database.

Installation

$ composer require crypto-technology/cryptocurrency

Usage

# 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());

More information can be found in the CryptocurrencyInterface interface PhpDocumentation.
The Cryptocurrency class contains, in addition to the get methods, also set methods (only for description and for project, explorer and sourcecode urls), which allow you to momentarily overwrite the default values.

Changelog

Please see the CHANGELOG for more information on what has changed recently.

Testing

# For Windows system
$ composer test-win

# For Unix system
$ composer test-unix

Contributing

Your help is always welcome! Feel free to open issues, ask questions, talk about it and discuss this tool.
Of course there are some contributing guidelines and a code of conduct, which I invite you to check out.
For all other contributions, see below.

After every code changes, but before submit your pull request, please apply Php Cs Fixer code fixing:

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

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

Security

The CryptoTech\Cryptocurrency package will be checked for security vulnerabilities using Roave Security Advisories checker. If you discover any security related issues, please email security@cryptotech.srl instead of using the issue tracker.

Code

Credits

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

The GNU General Public License version 3. Please see the license file for more information. This work is licensed under the GNU GPL v3.