PHPackages                             devshed-io/arithmatic - 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. devshed-io/arithmatic

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

devshed-io/arithmatic
=====================

Chainable math methods in php

1.5.1(4y ago)0126.7k↓48.5%1MITPHPPHP ^7.4|^8.0

Since Jun 29Pushed 4y agoCompare

[ Source](https://github.com/devshed-io/arithmatic)[ Packagist](https://packagist.org/packages/devshed-io/arithmatic)[ RSS](/packages/devshed-io-arithmatic/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (20)Used By (0)

Arithmatic
==========

[](#arithmatic)

 [![Tests](https://github.com/devshed-io/arithmatic/actions/workflows/phpunit.yml/badge.svg)](https://github.com/devshed-io/arithmatic/actions/workflows/phpunit.yml) [![Latest Release](https://camo.githubusercontent.com/289e2719a930ea95a9f7dd6aca372c99f9628f8ffb5096136d9c2af5eb1e9271/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f646576736865642d696f2f61726974686d617469633f6c6162656c3d4c617465737425323052656c65617365)](https://github.com/devshed-io/arithmatic/releases) [![License](https://camo.githubusercontent.com/681c80d133a50df8aa8993da11511fa41798076696293d8dd0f7c58de88c7c89/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f646576736865642d696f2f61726974686d61746963)](https://packagist.org/packages/devshed-io/aritmatic) [![Total Downloads](https://camo.githubusercontent.com/b65a82965c51614f627bf8baac7cd2ac356aa5b504c4b6ef1931dbbe0f6641bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646576736865642d696f2f61726974686d61746963)](https://packagist.org/packages/devshed-io/arithmatic)

Chainable math methods for PHP. Designed to make working with math more fluent and easier to read.

### Installation (via Composer)

[](#installation-via-composer)

```
composer require devshed-io/arithmatic
```

### Usage

[](#usage)

Basic usage allows you to chain methods for better readability:

```
Arithmatic
    ::start(5)
    ->add(5)
    ->subtract(7);
    ->divide(2);
    ->multiply(7)
    ->output();
```

The when method will execute the given callback when the first argument given to the method evaluates to true:

```
Arithmatic
    ::start(10)
    ->when(true, fn (Arithmatic $calculation) => $calculation->subtract(5))->output();
```

When also provides a third method that will run when the conditional evaluates to false:

```
Arithmatic
    ::start(10)
    ->when(
        false,
        fn (Arithmatic $calculation) => $calculation->subtract(5),
        fn (Arithmatic $calculation) => $calculation->add(5), // This will run...
    )
    ->output();
```

Arithmatic also provides the underlying run API so you can chain methods with arrays:

```
Arithmatic
    ::make(10)
    ->run([
        'add' => 5,
        'divide' => 2,
        'round'
    ])
    ->output(); // 3
```

N.B. Unless you call `output`, arithmatic will provide an instance of itself. It can be coerced to a string using the `__toString()` or `(string)` methods.

### Available Methods

[](#available-methods)

- percentageOf
- percentageChange
- divide
- subtract
- add
- multiply
- mean
- round
- clamp
- clone

### Testing (with Docker Compose)

[](#testing-with-docker-compose)

```
docker-compose run --rm php vendor/bin/phpunit --testdox
```

### License

[](#license)

[MIT license](https://opensource.org/licenses/MIT)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

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

Recently: every ~40 days

Total

19

Last Release

1650d ago

Major Versions

0.5.0 → 1.0.02021-05-31

PHP version history (2 changes)1.0.0PHP ^7.4

1.5.1PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/166fda3ead6725d85ddd77ff3c89c085e9522a5501c831f2fca5b11271d6ef4e?d=identicon)[Charles Bowen](/maintainers/Charles%20Bowen)

---

Top Contributors

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

---

Tags

libraryfluentchainableequationsmaths

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/devshed-io-arithmatic/health.svg)

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

###  Alternatives

[league/iso3166

ISO 3166-1 PHP Library

70036.3M116](/packages/league-iso3166)[dekor/php-array-table

PHP Library for printing associative arrays as text table (similar to mysql terminal console)

296.6M2](/packages/dekor-php-array-table)

PHPackages © 2026

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