PHPackages                             weight/weight - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. weight/weight

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

weight/weight
=============

Weight Class

v1.0.2(12y ago)445MITPHPPHP &gt;=5.3.0

Since May 3Pushed 12y ago1 watchersCompare

[ Source](https://github.com/php-mod/weight)[ Packagist](https://packagist.org/packages/weight/weight)[ RSS](/packages/weight-weight/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (1)Versions (3)Used By (0)

PHP Weight Class
================

[](#php-weight-class)

PHP Weight Class helps developers to work with mass units.

Examples
========

[](#examples)

Two ways to create new weight
-----------------------------

[](#two-ways-to-create-new-weight)

1-

```
$weight = new Weight(300, new Unit('KG'));
echo $weight; // 300 Kg
$wight->getValue() // returns 300
$weight->getUnit() // return Weight/Unit of KG.

```

2-

```
$weight = new Weight(15, 'KG');

```

Print formatted weight
----------------------

[](#print-formatted-weight)

```
echo $weight;

```

shows

```
300 Kg

```

Convert to another unit
-----------------------

[](#convert-to-another-unit)

```
$kgs = new Weight(300, new Unit('KG'));
$grams = $kgs->to(UNIT::GRAM);
echo (string) $grams;

```

shows

```
300,000.00 g

```

Another way to convert
----------------------

[](#another-way-to-convert)

```
$tonnes = $kgs->to('tonne');
echo (string) $tonnes;

```

shows

```
0.30 Mg

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~0 days

Total

3

Last Release

4394d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8da2a4376a9b330628e63e6d5b11ab407c17549b955b65adc19ca49b914e5fae?d=identicon)[amouhzi](/maintainers/amouhzi)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/weight-weight/health.svg)

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

PHPackages © 2026

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