2017 © Pedro Peláez
 

library quantity

PHP value objects for quantities

image

phospr/quantity

PHP value objects for quantities

  • Tuesday, February 9, 2016
  • by tomhv
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,712 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 18 Versions
  • 3 % Grown

The README.md

Phospr/Quantity

Build Status Coverage Status, (*1)

A library to represent various quantities as value objects with the ability to convert from one Unit of Measurement to another. Inspired by mathiasverraes/money., (*2)

A Quantity is made up of an amount (expressed as a Fraction) and a Uom (Unit of Measure)., (*3)

Currently, only Weight is implemented, but other possibilities include Quantity, Volume, Length etc., (*4)

$weight = new Weight(new Fraction(14), new Uom('OZ'));

Usage

Creating Uoms

Units of Measure can be created in the following manner. These two examples are equivalent:, (*5)

$pounds = new Uom('LB');
$pounds = Uom::LB();

Creating Quantities

Quantities can be created in any of the following ways. These three examples are equivalent:, (*6)

$weight = new Weight(new Fraction(10), new Uom('LB'));
$weight = new Weight(new Fraction(10), Uom::LB());
$weight = Weight::LB(10);

Converting Quantities

In the following example, we convert 2 lb (pounds) into ounces:, (*7)

echo Weight::LB(2)->to(Uom::OZ()); // 32

Using Fractions

The amount part of a Quantity is expressed as a Fraction. This allows us to convert Quantities accurately:, (*8)

echo Weight::OZ(28)->to(Uom::LB()); // 1 3/4 LB

Installation

{
    "require": {
        "phospr/quantity": "dev-master"
    }
}

The Versions

09/02 2016

dev-master

9999999-dev

PHP value objects for quantities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Haskins-Vaughan

09/02 2016

v1.2.0

1.2.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Haskins-Vaughan

02/02 2016

v1.1.0

1.1.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Haskins-Vaughan

26/01 2016

v1.0.0

1.0.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Haskins-Vaughan

12/01 2016

v0.12.0

0.12.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Haskins-Vaughan

10/01 2016

v0.11.0

0.11.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Haskins-Vaughan

09/01 2016

v0.10.0

0.10.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Haskins-Vaughan

11/11 2015

v0.9.0

0.9.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Haskins-Vaughan

05/11 2015

v0.8.0

0.8.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Haskins-Vaughan

05/11 2015

v0.7.0

0.7.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • yeriki/fractions >=0.1.0, <1.0

 

The Development Requires

by Tom Haskins-Vaughan

20/05 2015

v0.6.0

0.6.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • yeriki/fractions >=0.1.0, <1.0

 

The Development Requires

by Tom Haskins-Vaughan

19/05 2015

v0.5.0

0.5.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • yeriki/fractions >=0.1.0, <1.0

 

The Development Requires

by Tom Haskins-Vaughan

18/05 2015

v0.4.0

0.4.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • yeriki/fractions dev-master

 

The Development Requires

by Tom Haskins-Vaughan

18/05 2015

v0.3.2

0.3.2.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • yeriki/fractions dev-master

 

The Development Requires

by Tom Haskins-Vaughan

17/05 2015

v0.3.1

0.3.1.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • yeriki/fractions dev-master

 

The Development Requires

by Tom Haskins-Vaughan

17/05 2015

v0.3.0

0.3.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • yeriki/fractions dev-master

 

The Development Requires

by Tom Haskins-Vaughan

16/05 2015

v0.2.0

0.2.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • yeriki/fractions dev-master

 

The Development Requires

by Tom Haskins-Vaughan

13/05 2015

v0.1.0

0.1.0.0

PHP value objects for quantities

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan