2017 © Pedro Peláez
 

library php-conversion

Library for converting units and sizes.

image

crisu83/php-conversion

Library for converting units and sizes.

  • Wednesday, May 18, 2016
  • by crisu83
  • Repository
  • 6 Watchers
  • 97 Stars
  • 23,575 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 14 Forks
  • 2 Open issues
  • 18 Versions
  • 16 % Grown

The README.md

php-conversion

Build Status, (*1)

Library for converting units and sizes in PHP., (*2)

Units supported

  • Acceleration
  • Angle
  • Area
  • Digital information
  • Electric current
  • Frequency
  • Fuel consumption
  • Length
  • Luminous Intensity
  • Mass
  • Power
  • Pressure
  • Speed
  • Temperature
  • Time
  • Velocity
  • Voltage
  • Volume

Sizes supported

  • Hat size
  • Child shoe size

Number base supported

  • Binary
  • Octal
  • Decimal
  • Hexadecimal

Usage

Example usage:, (*3)

use Crisu83\Conversion\Quantity\DigitalInformation\DigitalInformation;
use Crisu83\Conversion\Quantity\Length\Length;
use Crisu83\Conversion\NumberBase\NumberBase;
use Crisu83\Conversion\Size\HatSize\HatSize;
use Crisu83\Conversion\Size\ShoeSize\ChildShoeSize;

use Crisu83\Conversion\Quantity\Length\Unit as LengthUnit;
use Crisu83\Conversion\Quantity\DigitalInformation\Unit as DIUnit;
use Crisu83\Conversion\Size\HatSize\System as HatSizeSystem;
use Crisu83\Conversion\Size\ShoeSize\System as ShoeSizeSystem;

require(dirname(__DIR__) . '/vendor/autoload.php');

$length = new Length(1, LengthUnit::METRE);
echo $length . '<br>';
echo $length->add(1, LengthUnit::FOOT) . '<br>';
echo $length->add(5)->sub(2, LengthUnit::FOOT) . '<br>';
echo $length->to(LengthUnit::YARD) . '<br>';

echo '<br>';

$di = new DigitalInformation(1000, DIUnit::MEGABYTE);
echo $di . '<br>';
echo $di->to(DIUnit::BIT)->out(2, '.', '') . '<br>';
echo $di->to(DIUnit::GIGABIT) . '<br>';
echo $di->to(DIUnit::TERABYTE)->out(10) . '<br>';

echo '<br>';

$number = new NumberBase("0xff", NumberBase::HEXADECIMAL);
echo $number . '<br>';
echo $number->to(NumberBase::DECIMAL) . '<br>';
echo $number->to(NumberBase::OCTAL) . '<br>';
echo $number->to(NumberBase::BINARY) . '<br>';

echo '<br>';

$hatSize = new HatSize(40, HatSizeSystem::CENTIMETRE);
echo $hatSize . '<br>';
echo $hatSize->to(HatSizeSystem::AMERICAN) . '<br>';
echo $hatSize->to(HatSizeSystem::BRITISH) . '<br>';
echo $hatSize->to(HatSizeSystem::INCH) . '<br>';

echo '<br>';

$shoeSize = new ChildShoeSize(20, ShoeSizeSystem::EUROPEAN);
echo $shoeSize . '<br>';
echo $shoeSize->to(ShoeSizeSystem::AMERICAN) . '<br>';
echo $shoeSize->to(ShoeSizeSystem::BRITISH) . '<br>';
echo $shoeSize->to(ShoeSizeSystem::INCH) . '<br>';

Sample output:, (*4)

1.00 m
1.30 m
5.70 m
6.23 yd

1,000.00 MB
8388629474.89 b
7.81 Gb
0.0009534451 TB

0xff
255
o377
b11111111

40 cm
4 US
4 7/8 UK
15.748 in

20 EUR
4.5 - 5 US
3.5 - 4 UK
4.625 in

The Versions

18/05 2016

dev-master

9999999-dev

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4

 

The Development Requires

17/06 2014

0.5.2

0.5.2.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.4

 

The Development Requires

22/10 2013

dev-develop

dev-develop

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Development Requires

22/10 2013

0.5.1

0.5.1.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Development Requires

22/10 2013

0.5.0

0.5.0.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Development Requires

21/10 2013

0.4.5

0.4.5.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Development Requires

21/10 2013

0.4.4

0.4.4.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Development Requires

21/10 2013

0.4.3

0.4.3.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Development Requires

21/10 2013

0.4.2

0.4.2.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Development Requires

20/10 2013

0.4.1

0.4.1.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Development Requires

20/10 2013

0.4.0

0.4.0.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

The Development Requires

20/10 2013

0.3.1

0.3.1.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

19/10 2013

0.3.0

0.3.0.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

19/10 2013

0.2.0

0.2.0.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

19/10 2013

0.1.3

0.1.3.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

19/10 2013

0.1.2

0.1.2.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

19/10 2013

0.1.1

0.1.1.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0

19/10 2013

0.1.0

0.1.0.0

Library for converting units and sizes.

  Sources   Download

Apache-2.0