PHPackages                             louisgab/php-calc - 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. louisgab/php-calc

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

louisgab/php-calc
=================

Simple fluent float manipulation library

v0.2.0(5y ago)161391MITPHPPHP ^7.4CI failing

Since Dec 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/louisgab/php-calc)[ Packagist](https://packagist.org/packages/louisgab/php-calc)[ Docs](https://github.com/louisgab/number)[ RSS](/packages/louisgab-php-calc/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (2)Dependencies (1)Versions (6)Used By (0)

Calc
====

[](#calc)

[![Tests](https://github.com/louisgab/php-calc/workflows/tests/badge.svg)](https://github.com/louisgab/php-calc/workflows/tests/badge.svg)[![Packagist Version](https://camo.githubusercontent.com/a00a171ddb9ef8d3d0bed3136c17b269fed19e59743120f877b010b17d840900/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f7569736761622f7068702d63616c632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/louisgab/php-calc)[![Packagist Downloads](https://camo.githubusercontent.com/aea8238a8486fdcd9b4ea6dd0724aeeea4d904f549bfe4fab3abec5c7069faeb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f7569736761622f7068702d63616c632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/louisgab/php-calc)[![GitHub license](https://camo.githubusercontent.com/4ce7c9b280d172860269474b99fb0d7c7c8dcd7714908bc10991229a92226e3d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6c6f7569736761622f7068702d63616c632e7376673f7374796c653d666c61742d737175617265)](https://github.com/louisgab/php-calc/blob/master/LICENSE)

💯 Simple fluent float manipulation library.

Calc aims to provide tools for easy and readable calculations, without any dependency.
It comes with `Number` which is an immutable value object that enables fluent float manipulations.

Why
---

[](#why)

If you ever worked with a codebase full of that kind of crap:

```
$result = round(($b != 0 ? ((1+$a)/$b) : $c)*0.25, 2)
```

I'm sure you will enjoy that:

```
$result = Number::of($b)
    ->when(Number::of($b)->isZero(),
        fn($b) => $c
        fn($b) => Number::one()->plus($a)->divide($b),
    )
    ->multiply(0.25)
    ->round(2)
    ->value()
```

You may think it's like [brick/math](https://github.com/brick/math), which is a really great package, but Calc serves a different purpose.
If floats are good enough for you - and unless you're dealing with sensible data like accounting or science, it should be - then using GMP or bcmath is overkill.

That's what Calc is made for, still using floats while enjoying nice readability. Another good point is that it handles floating point problems (e.g `0.1 + 0.2 == 0.3 // false`) as much as possible, so you don't have to think about it each time (and if you are working with junior developers, it will save them from having problems they didn't even know existed!).

Install
-------

[](#install)

Via composer:

```
composer require louisgab/php-calc
```

Usage
-----

[](#usage)

Simple as:

```
use Louisgab\Calc\Number;

Number::of($anything);
```

And good as :

```
public function carsNeeded(Number $people, Number $placesPerCar): int
{
    return $people->divide($placesPerCar)->round(0)->toInt();
}
```

Please see [DOCS](DOCS.md)

Testing
-------

[](#testing)

```
composer test
```

Roadmap
-------

[](#roadmap)

- `Number`
- `Fraction`
- `Percentage`

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md)

Contributing
------------

[](#contributing)

Highly welcomed!

License
-------

[](#license)

Please see [The MIT License (MIT)](LICENSE.md).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

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

Total

2

Last Release

1970d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9028947?v=4)[Louis-Gabriel](/maintainers/louisgab)[@louisgab](https://github.com/louisgab)

---

Top Contributors

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

---

Tags

phpfluentnumberfloat

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/louisgab-php-calc/health.svg)

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

###  Alternatives

[wilon/php-number2chinese

PHP数字转为汉字描述、人民币大写方法。

14632.0k1](/packages/wilon-php-number2chinese)[selvinortiz/flux

Fluent regular expressions in PHP.

3372.0k1](/packages/selvinortiz-flux)

PHPackages © 2026

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