2017 © Pedro Peláez
 

library common-measurement

Measurements and their corresponding units and dimensions

image

binsoul/common-measurement

Measurements and their corresponding units and dimensions

  • Thursday, April 28, 2016
  • by binsoul
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

common-measurement

Latest Version on Packagist ![Software License][ico-license] Total Downloads, (*1)

This package provides classes for modeling and working with measurements and their corresponding units and dimensions., (*2)

Install

Via composer:, (*3)

``` bash $ composer require binsoul/common-measurement, (*4)


## Usage Output a length in metres. ``` php <?php use BinSoul\Common\Measurement\Measure; use BinSoul\Common\Measurement\Measure\LengthMeasure; use BinSoul\Common\Measurement\SystemOfUnits\StandardUnits; use BinSoul\Common\Measurement\SystemOfUnits\USCustomaryUnits; include 'vendor/autoload.php'; function output(LengthMeasure $length) { $standardUnits = new StandardUnits(); $converted = $length->to($standardUnits->METRE); echo sprintf( "%s %s = %s %s\n", $length->getValue(), $length->getUnit()->getSymbol(), $converted->getValue(), $converted->getUnit()->getSymbol() ); } $standardUnits = new StandardUnits(); $usUnits = new USCustomaryUnits($standardUnits); output(Measure::valueOf(1, $standardUnits->CENTIMETRE)); // 1 cm = 0.01 m output(Measure::valueOf(1, $standardUnits->KILOMETRE)); // 1 km = 1000 m output(Measure::valueOf(1, $usUnits->INCH)); // 1 in = 0.0254 m output(Measure::valueOf(1, $usUnits->MILE)); // 1 mi = 1609.344 m

Testing

bash $ composer test, (*5)

License

The MIT License (MIT). Please see License File for more information., (*6)

The Versions

28/04 2016

dev-master

9999999-dev https://github.com/binsoul/common-measurement

Measurements and their corresponding units and dimensions

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

common measurement