Convert from and to almost anything

1.0.0 2015-11-26 12:13 UTC

This package is auto-updated.

Last update: 2024-05-29 02:40:39 UTC



Converter is a PHP library that allows easy conversion between different 
metrics of a kind. 

Conversion between meter and millimeter might be easy and can be implemented 
over and over again, but what about the conversion from millimeter to
nautical miles? Or what about converting latitude/longitude to UTM? Or what
about converting degree Farenheit to Kelvin?

The answer is easy: Use this Converter


* PHP in version 5.3
* Nothing else


* Put the Converter-Folder wherever you like and include that location into your
  include path.
* If you do not use an autoloader, you should do so!

Have a look at this example-code to convert from Nautical Miles to yards.


  $miles      = 12;
  $from       = new \Converter\Length\NauticalMiles();
  $to         = new \Converter\Length\Yard();
  $miles2Yard = \Converter\Converter::factory($from, $to);
  echo $miles2Yard->convert($miles);
  // 24304.461942257
So a once defined Converter-Object can be reused as often as you like. 

How does it work

Clearly by magic. everything else would not be sophisticated enough.....

For those of you that do not believe in magic, the explanation is quite simple.
Converter uses an internal measure to and from which everything is converted.

So in the previous example the Converter calls Length\NauticalMiles to convert
the input to the internal measure and hands that over to Length\BritishYard to
convert the internal measure to british yards.

Normaly the internal measure is one of the international standard measurements
so for lengths the internal measure is meter.

For an overview have a look at the following list:

:Length: meter
:Area: squaremeter
:Volume: cubicmeter
:Geographical: Latitude/Longitude/Height above NN
:Temperature: Kelvin
:Color: CIELAB