PHPackages                             vbpupil/measurement-converter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. vbpupil/measurement-converter

ActiveLibrary

vbpupil/measurement-converter
=============================

A simple but effective measurement converter which allows you to quickly create measurement objects that can be easily converted into other measurement formats, for example converting an Imperial measurement into Metric.

1.3.1(8y ago)0184MITPHP

Since Sep 12Pushed 7y ago1 watchersCompare

[ Source](https://github.com/vbpupil/measurement-converter)[ Packagist](https://packagist.org/packages/vbpupil/measurement-converter)[ RSS](/packages/vbpupil-measurement-converter/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (3)Versions (7)Used By (0)

Quality Assurance
-----------------

[](#quality-assurance)

[![PHP 5.6](https://camo.githubusercontent.com/88093c79af42bd3c07f4d6aa378289e1f5450411c56753b0323bd7d8b9b1f9ee/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e362d626c75652e737667)](https://camo.githubusercontent.com/88093c79af42bd3c07f4d6aa378289e1f5450411c56753b0323bd7d8b9b1f9ee/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e362d626c75652e737667)[![PHP 7](https://camo.githubusercontent.com/d23ce60b89c28c023d0ca69981ec9afbb17eb08a9cd1b609fd84c15d0732b7ce/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372d626c75652e737667)](https://camo.githubusercontent.com/d23ce60b89c28c023d0ca69981ec9afbb17eb08a9cd1b609fd84c15d0732b7ce/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372d626c75652e737667)[![Build Status](https://camo.githubusercontent.com/e32eccdc9b8f3f905650a1c55fcd8f98e404153c6fcb7c2fec7f73e5fe38f825/68747470733a2f2f7472617669732d63692e6f72672f7662707570696c2f6d6561737572656d656e742d636f6e7665727465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vbpupil/measurement-converter)[![Code Climate](https://camo.githubusercontent.com/301b5ee367b0ddc28549f9af1b5891b188dd5c6fc9587a993962da907c8697e2/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7662707570696c2f4d6561737572656d656e74436f6e7665727465722f6261646765732f6770612e737667)](https://travis-ci.org/vbpupil/measurement-converter)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)

Measurement Converter
=====================

[](#measurement-converter)

A simple but effective measurement converter which allows you to quickly create measurement objects that can be easily converted into other measurement formats, for example converting an Imperial measurement into Metric.

Currently this package supports the following:

1. Metric Linears
2. Imperial Linears
3. Metric Cubic
4. Imperial Cubic
5. Weights Conversion
    - Tonne
    - US Ton
    - Imperial Ton

By creating a linear measurement unit object you immediately inherit the values of that conversion to your units counterparts. For example, by creating a **1 Inch Object**you also have access to the **Feet**, **Yard** &amp; **Mile** measurements off the bat

#### Supported Units

[](#supported-units)

TypeUnitIdentifiedLinear MetricMillemetermmCentimetercmMetermKilometerkmLinear ImperialInchinFeetftYardydMilemlWeightTonneUS TonImperial Ton### Usage Examples

[](#usage-examples)

#### Metric Example

[](#metric-example)

**1. create a 50 foot object**

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

**2. convert that into millimeters**

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

**3. get the new millimeters object**

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

**4. convert millemeters into inches &amp; get the inches object**

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

#### Cubic Example

[](#cubic-example)

**1. create a width, depth &amp; height object and pass these into the cubic constructor**

```
$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')));
```

#### Weight Example

[](#weight-example)

**1. to convert the cubic measurement into a weight simply pass in the SUPPORTED matrial name &amp; cubic object**

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

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

**2. you can also supply your own density measurement, which will be added to the density array as `custom`**

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

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

#### Simple Conversion Example

[](#simple-conversion-example)

**1. start by creating a simple 20 foot Imperial LinearUnit object**

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

**2. then convert this into a cm Metric LinearUnit object**

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

#### Supported Materials &amp; Densities

[](#supported-materials--densities)

MaterialDensity, kg/m3acetone795acetylene1.1709air1.928alcohol789ammonia0.7714antifreeze1112argon1.7839asphalt1100azote1.251beer1041brass8500bronze8600butter920cadmium8640caprolon1150carbon\_monoxide1.25cast\_iron7300cement2900chlorine\_oxide3.89chlorine3.22clay1750concrete2400concrete\_solution2100copper8900crushed\_stone1350diesel860dioxide\_of\_chlorine3.09ethane1356ether740fiberglass1900fluorine1695fluoroplast1400garbage250gasoline750glass2500glycerin1260gold19300gravel1550ground1800helium0.1785hydrogen0.08987ice917indium7300kerosene810krypton3.74lead11400liquid\_hydrogen70mercury13600methane0.6682methyl\_alcohol810milk1030neon0.8999nitrous\_oxide1978nitrogen1251nitrogen\_fluoride2.9nitric\_oxide1.3402oil850olive\_oil920oxygen1.429ozone2.22paint1300paladius12160paper950petrol750phosphorous\_fluoride3907platinum21450polyamide1150polycarbonate1200polyethylene960polypropylene900polystyrene1050polyvinyl\_chloride1400porcelain2300propane1.864radon9.73rubber1050sand1800sea\_water1025silver11500slag3550snow200soil1800steel7800stone2200sunflower oil915sulfuric\_acid1840tin7300trimethylamine2.58tungsten19300viniplast1450water1000wood\_birch650wood\_bud690wood\_cork480wood\_larch660wood\_linden530wood\_pine520wood\_spruce450xenon5.89zinc7130

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~50 days

Total

5

Last Release

2961d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/afdce7c1b24b3c017b5381c2708b9dd27b9b694de9b09b49ee500a26d3f46364?d=identicon)[vbpupil](/maintainers/vbpupil)

---

Top Contributors

[![vbpupil](https://avatars.githubusercontent.com/u/2638990?v=4)](https://github.com/vbpupil "vbpupil (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vbpupil-measurement-converter/health.svg)

```
[![Health](https://phpackages.com/badges/vbpupil-measurement-converter/health.svg)](https://phpackages.com/packages/vbpupil-measurement-converter)
```

###  Alternatives

[php-debugbar/php-debugbar

Debug bar in the browser for php application

4.4k21.3M40](/packages/php-debugbar-php-debugbar)[drush/drush

Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

2.4k57.4M685](/packages/drush-drush)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
