2017 © Pedro Peláez
 

library byte

byte conversion utility

image

jschaedl/byte

byte conversion utility

  • Friday, December 20, 2013
  • by jschaedl
  • Repository
  • 1 Watchers
  • 7 Stars
  • 1,297 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 11 % Grown

The README.md

Byte

A simple byte conversion utility to make conversion of byte values easier! It is built for PHP 5.3+., (*1)

Build Status Latest Unstable Version Latest Unstable Version Total Downloads Dependencies Status, (*2)


Installation

Install the library using composer. Add the following to your composer.json:, (*3)

"require": {
        "jschaedl/byte": "dev-master"
}

And run the composer install command in terminal., (*4)

sudo composer.phar install

Usage example

<?php
    $converter = new \Byte\ByteConverter();

    // convert to bytes
    $converter->getBytes('1b');     // 1
    $converter->getBytes('1k');     // 1024
    $converter->getBytes('1m');     // 1048576
    $converter->getBytes('1g');     // 1073741824

    // convert to kilobytes
    $converter->getKBytes('1b');    // 0.0009765625
    $converter->getKBytes('1k');    // 1
    $converter->getKBytes('1m');    // 1024
    $converter->getKBytes('1g');    // 1048576

    // convert to megabytes
    $converter->getMBytes('1b');    // 0.00000095367431640625
    $converter->getMBytes('1k');    // 0.0009765625
    $converter->getMBytes('1m');    // 1
    $converter->getMBytes('1g');    // 1024

    // convert to gigabytes
    $converter->getGBytes('1b');    // 0.00000000093132257461548
    $converter->getGBytes('1k');    // 0.00000095367431640625
    $converter->getGBytes('1m');    // 0.0009765625
    $converter->getGBytes('1g');    // 1 

Author

Jan Schädlich, (*5)

License

MIT Public License, (*6)

Bitdeli Badge, (*7)

The Versions