PHPackages                             strukt/math - 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. strukt/math

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

strukt/math
===========

Math Operations

v1.1.0-alpha(1y ago)05331MITPHPPHP ^8.1

Since May 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/struktapp/strukt-math)[ Packagist](https://packagist.org/packages/strukt/math)[ RSS](/packages/strukt-math/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (4)Used By (1)

Strukt Math
===========

[](#strukt-math)

Number (Value Objects)
----------------------

[](#number-value-objects)

```
$num = number(1000);
$num = $num->add(200);//1200
$num = $num->subtract(100);//1100
$num = $num->times(2);//2200 multiplication
$num = $num->parts(4);//550 division
$rem = $num->mod(9);//1 modulus
$num = $num->raise(2);//302500 power
list($num1, $num2) = $num->ratio(1,1);//151250,151250
list($num1, $num2) = $num->ratio(1,3);//75625,226875
list($num1, $num2, $num3) = $num->ratio(1,1,3);//60500,60500,181500
$num->gt(302499);//true; greaterthan
$num->gte(302500);//true greaterthanorequals
$num->lt(302499);//false lessthan
$num->lte(302501);//true lessthanorequals
$num->negate()->equals(-302500)
$num->yield();//return native number
$num->reset();//0
Number::create(1000000)->format();//1,000,000.00
Number::create(20.5111111)->round(2);//20.51
Number::random(4, 10, 20); //return 4 random numbers between 10 and 20
Number::create(10.1)->type();//double
echo $num;//return native number
```

Matrix
------

[](#matrix)

```
// $a = array(array(1,2,3),array(4,5,6),array(7,8,9));
$a = array(

    array(1,2,3),
    array(4,5,6),
    array(7,8,9)
);

// $b = array(array(11,22,33),array(44,55,66),array(77,88,99));
$b = array(

    array(11,22,33),
    array(44,55,66),
    array(77,88,99)
);

$c = (string)matrix($a)->multiply($b);
/** Result
[330,396,462]
[726,891,1056]
[1122,1386,165]
**/

$c = matrix($a)->multiply($b)->yield();
/** Result
array(
    array(330,396,462),
    array(726,891,1056),
    array(1122,1386,1650)
)
*/
```

Monad
-----

[](#monad)

```
// Linear Equation y = mx + c

$params = array("c"=>12, "m"=>3, "x"=>2)

// $y = monos($params)
//         ->next(fn($m, $x)=>$m * $x)
//         ->next(fn($mx, $c)=>$mx + $c)
//         ->next(fn($r)=>$r);

$y = monos($params)->next(fn($m, $x)=>$m * $x)->next(fn($mx, $c)=>$mx + $c)->next(fn($r)=>$r);

echo $y->yield();
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance43

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

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

Total

3

Last Release

469d ago

PHP version history (2 changes)v1.0.0-alphaPHP &gt;=7.4

v1.1.0-alphaPHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f77a56030c77ce25f7fcf6db800e45bb6a31bf3c07740b43aeabcdf5e9edec2?d=identicon)[pitsolu](/maintainers/pitsolu)

---

Top Contributors

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

---

Tags

matrixmatrix-operationsmonadsnumbervalue-object

### Embed Badge

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

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

###  Alternatives

[whitecube/laravel-sluggable

Generate slugs for your models automatically - even with translated attributes

2031.0k](/packages/whitecube-laravel-sluggable)[vendic/hyva-checkout-hide-business-fields

Hyvä checkout module to hide business fields for consumers

1353.2k1](/packages/vendic-hyva-checkout-hide-business-fields)

PHPackages © 2026

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