PHPackages                             kieranajp/combinator - 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. kieranajp/combinator

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

kieranajp/combinator
====================

Generates combinations of a set.

v0.1(9y ago)027.5k↓50%MITPHPPHP &gt;=7.0

Since Jun 9Pushed 9y agoCompare

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

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

Combinator
==========

[](#combinator)

**Generates combinations of a set**

A combination is a set of size *k* from a number of values &gt; *k* that does not repeat.

For example, given the values `Jim, Jane, Bob, Susan, Ralph`, all the possible combinations of size `3` are as follows:

```
Jim, Jane, Bob
Jim, Jane, Susan
Jim, Jane, Ralph
Jim, Bob, Susan
Jim, Bob, Ralph
Jim, Susan, Ralph
Jane, Bob, Susan
Jane, Bob, Ralph
Jane, Susan, Ralph
Bob, Susan, Ralph

```

(credit to [this awesome calculator](http://www.statisticshowto.com/calculators/permutation-calculator-and-combination-calculator/) for the example).

Installation
------------

[](#installation)

`composer require kieranajp/combinator`

Usage
-----

[](#usage)

The provided `Combinator` class is an instance of [`Iterator`](http://php.net/manual/en/class.iterator.php), so combinations can be collected by looping over it.

For example:

```
use Kieranajp\Combinator\Combinator;

$size = 3;
$combinator = new Combinator([1, 2, 3, 4, 5], $size);

$items = [];
foreach ($c as $item) {
    $items[] = $item;
}
```

The `$items` array will now contain all possible combinations of size `$size`.

Contributing &amp; Roadmap
--------------------------

[](#contributing--roadmap)

Pull requests are welcome. Please adhere to PSR-2. I intend to add a Permutator to this package, as well.

License
-------

[](#license)

MIT License

Copyright (c) 2016 Kieran Patel

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

3630d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/986acba5713cdb47bd0f0e9b0e7988f3b4a2cc43f40bdcbb9820a64f79d6516d?d=identicon)[kieranajp](/maintainers/kieranajp)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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