Skip to content

NeoBlack/BaseConverter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BaseConverter

Build Status GitHub version Code Coverage

Description

BaseConverter is a simple and small library to convert interger values to different other bases and back.

Install via composer

Just run the following command in your project root:

composer require neoblack/base-converter:~1.0

Example usage

<?php
require_once 'vendor/autoload.php';
use NeoBlack\BaseConverter\BaseConverter;

$number = 100;

$base64Number = BaseConverter::toBase($number, BaseConverter::BASE64); // Result: 1A
$base62Number = BaseConverter::toBase($number, BaseConverter::BASE62); // Result: 1C
$base32Number = BaseConverter::toBase($number, BaseConverter::BASE32); // Result: 34
$base16Number = BaseConverter::toBase($number, BaseConverter::BASE16); // Result: 64

BaseConverter::to10Base($base64Number, BaseConverter::BASE64); // Result: 100
BaseConverter::to10Base($base62Number, BaseConverter::BASE62); // Result: 100
BaseConverter::to10Base($base32Number, BaseConverter::BASE32); // Result: 100
BaseConverter::to10Base($base16Number, BaseConverter::BASE16); // Result: 100

Developer Notes

If you want to contribute, fork this repository and send a pull request.

Unit Test

./bin/phpunit -c Build/UnitTests.xml

Coverage report

rm -rf docs
./bin/phpunit -c Build/UnitTests.xml --coverage-html docs

License

The MIT License (MIT) see license file.