PHP Classes

PHP Base Converter: Convert number representations between two bases

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 58 All time: 10,536 This week: 206Up
Version License PHP version Categories
baseconverter 1.0MIT/X Consortium ...5PHP 5, Text processing, Conversion
Description 

Author

This package can convert number representations between two bases.

It can take a string with a value represented in a given base and can convert the number to another base.

The class returns a new string with the number represented in the new base.

It supports different bases like base 64, base 32, and base 16.

Picture of FN
Name: FN <contact>
Classes: 2 packages by
Country: ???
Age: 54
All time rank: 4442
Week rank: 214 Up

Documentation

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.


  Files folder image Files (35)  
File Role Description
Files folder image.github (2 files)
Files folder imageBuild (2 files)
Files folder imagedocs (3 files, 5 directories)
Files folder imagesrc (2 directories)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (35)  /  .github  
File Role Description
  Accessible without login Plain text file ISSUE_TEMPLATE.md Data Auxiliary data
  Accessible without login Plain text file PULL_REQUEST_TEMPLATE.md Data Auxiliary data

  Files folder image Files (35)  /  Build  
File Role Description
  Accessible without login Plain text file UnitTests.xml Data Auxiliary data
  Accessible without login Plain text file UnitTestsBootstrap.php Class Class source

  Files folder image Files (35)  /  docs  
File Role Description
Files folder imageClasses (3 files)
Files folder imagecss (3 files)
Files folder imagefonts (1 file)
Files folder imagejs (7 files)
Files folder imageTests (2 files, 1 directory)
  Accessible without login HTML file BaseConverter.php.html Doc. Documentation
  Accessible without login HTML file dashboard.html Doc. Documentation
  Accessible without login HTML file index.html Doc. Documentation

  Files folder image Files (35)  /  docs  /  Classes  
File Role Description
  Accessible without login HTML file BaseConverter.php.html Doc. Documentation
  Accessible without login HTML file dashboard.html Doc. Documentation
  Accessible without login HTML file index.html Doc. Documentation

  Files folder image Files (35)  /  docs  /  css  
File Role Description
  Accessible without login Plain text file bootstrap.min.css Data Auxiliary data
  Accessible without login Plain text file nv.d3.min.css Data Auxiliary data
  Accessible without login Plain text file style.css Data Auxiliary data

  Files folder image Files (35)  /  docs  /  fonts  
File Role Description
  Accessible without login Plain text file glyphicons-halflings-regular.svg Data Auxiliary data

  Files folder image Files (35)  /  docs  /  js  
File Role Description
  Accessible without login Plain text file bootstrap.min.js Data Auxiliary data
  Accessible without login Plain text file d3.min.js Data Auxiliary data
  Accessible without login Plain text file holder.min.js Data Auxiliary data
  Accessible without login Plain text file html5shiv.min.js Data Auxiliary data
  Accessible without login Plain text file jquery.min.js Data Auxiliary data
  Accessible without login Plain text file nv.d3.min.js Data Auxiliary data
  Accessible without login Plain text file respond.min.js Data Auxiliary data

  Files folder image Files (35)  /  docs  /  Tests  
File Role Description
Files folder imageUnit (4 files)
  Accessible without login HTML file dashboard.html Doc. Documentation
  Accessible without login HTML file index.html Doc. Documentation

  Files folder image Files (35)  /  docs  /  Tests  /  Unit  
File Role Description
  Accessible without login HTML file BaseConverterTest.php.html Doc. Documentation
  Accessible without login HTML file BaseTestCase.php.html Doc. Documentation
  Accessible without login HTML file dashboard.html Doc. Documentation
  Accessible without login HTML file index.html Doc. Documentation

  Files folder image Files (35)  /  src  
File Role Description
Files folder imageClasses (1 file)
Files folder imageTests (1 directory)

  Files folder image Files (35)  /  src  /  Classes  
File Role Description
  Accessible without login Plain text file BaseConverter.php Class Class source

  Files folder image Files (35)  /  src  /  Tests  
File Role Description
Files folder imageUnit (2 files)

  Files folder image Files (35)  /  src  /  Tests  /  Unit  
File Role Description
  Accessible without login Plain text file BaseConverterTest.php Class Class source
  Accessible without login Plain text file BaseTestCase.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:58
This week:0
All time:10,536
This week:206Up