PHP code example of vbpupil / measurement-converter

1. Go to this page and download the library: Download vbpupil/measurement-converter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vbpupil / measurement-converter example snippets


$feet= LinearUnitBuilder::build(new FloatType(18), new StringType('ft'));
dump($feet->getHumanReadableLong());

$converter = new LinearUnitsConverter($feet, new StringType('mm'));

$mm = $converter->get();
dump($mm->getHumanReadableLong());

$converter = new LinearUnitsConverter($mm, new StringType('in'));
$inch = $converter->get();
dump($inch->getHumanReadableLong());

$width = LinearUnitBuilder::build(new FloatType(18), new StringType('m'));
$depth = LinearUnitBuilder::build(new FloatType(42), new StringType('m'));
$height = LinearUnitBuilder::build(new FloatType(3), new StringType('cm'));

$cubic = new CubicUnit($width, $depth, $height);
dump($cubic->getValue(new StringType('mm')));

$tonnage = new WeightTonnageDensityConverter('soil', $cubic);

dump($cubic);
dump($tonnage->getValue());

$tonnage = new WeightTonnageDensityConverter(1.2, $cubic);

dump($cubic);
dump($tonnage->getValue());

$length = LinearUnitBuilder::build(new FloatType(20), new StringType('ft'));

$length = LinearUnitBuilder::build(
                    new FloatType((new Conversion($l))->into(
                        new StringType('cm')
                    )),
                    new StringType(
                        'cm'
                    ));