2017 © Pedro Peláez
 

library unit-converter

image

koesie10/unit-converter

  • Tuesday, November 15, 2016
  • by koesie10
  • Repository
  • 0 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PHP Lua Serializer/Deserializer

Build Version License Code Coverage Code Quality Downloads, (*1)

This is a SI unit converter for PHP, that will convert all kinds of units from one into the other, with support for composite units., (*2)

Installation

Install with Composer:, (*3)

composer require koesie10/unit-converter

Usage

Simply create a \Vlaswinkel\UnitConverter\UnitConverter object and call the convert method:, (*4)

$converter = new \Vlaswinkel\UnitConverter\UnitConverter();

echo $converter->convert('1', 'm/s', 'km/h'); // prints 3.6, as expected

This library will try to use BC math if it is available, which is highly recommended for more accurate results. In that case, it is recommended to always supply strings to the convert function, otherwise there will still be floating point errors., (*5)

Note: If you do not get proper results, check that you have set the scale for BC math correctly. It is recommended to set the value to at least 3, but for more precision, it is recommended to increase the value more., (*6)

If you would like to use the default PHP math functions, which will have floating point errors but will not require a scale, you can instantiate the UnitConverter as follows:, (*7)

$converter = new \Vlaswinkel\UnitConverter\UnitConverter(null, new \Vlaswinkel\UnitConverter\Math\DefaultMathWrapper());

Running tests

You can run automated unit tests using PHPUnit after installing dependencies:, (*8)

vendor/bin/phpunit

License

This library is licensed under the MIT license. See the LICENSE file for details., (*9)

The Versions

15/11 2016

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Koen Vlaswinkel

15/11 2016

v0.1

0.1.0.0

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Koen Vlaswinkel