PHPackages                             coshi/variator - 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. coshi/variator

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

coshi/variator
==============

Utils for generating arrays of data combinations

v0.0.2(9y ago)03.6k1MITPHPPHP 7.\*

Since Aug 23Pushed 9y ago8 watchersCompare

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

READMEChangelog (2)DependenciesVersions (3)Used By (1)

A simple library to generate arrays of values combinations.
-----------------------------------------------------------

[](#a-simple-library-to-generate-arrays-of-values-combinations)

Usage:

```
    $factory = new VariationFactory();
    $builder = new VariationsTreeBuilder($factory);

    $config = [
        'text' => [
            'type' => 'enum',
            'values' => ['first', 'second', 'third'],
        ],
    ];
    $variations = $builder->build($config);

    foreach ($variations as $values) {
        foreach($values as $value) {
            print($value); // displays first, second, third
        }
    }

```

More complex:

```
    $factory = new VariationFactory();
    $builder = new VariationsTreeBuilder($factory);

    $config = [
        'text' => [
            'type' => 'enum',
            'values' => ['first', 'second', 'third'],
        ],
        'number' => [
            'type' => 'int',
            'min' => 0,
            'max' => 2
        ],
    ];
    $variations = $builder->build($config);

    foreach ($variations as $values) {
        echo sprintf('text: %s, number: %d', $values['text'], $values['number']);
        echo PHP_EOL;
    }

```

Output will be:

```
    text: first, number: 0
    text: second, number: 0
    text: third, number: 0
    text: first, number: 1
    text: second, number: 1
    text: third, number: 1
    text: first, number: 2
    text: second, number: 2
    text: third, number: 2

```

It can call methods and functions in order to get values:

```
    class DummyClass
    {
        public function someValues()
        {
            return [0, 1, 2];
        }
    }
    $factory = new VariationFactory();
    $builder = new VariationsTreeBuilder($factory);

    $config = [
        'text' => [
            'type' => 'enum',
            'values' => ['first', 'second', 'third'],
        ],
        'number' => [
            'type' => 'callback',
            'callback' => [DummyClass::class, 'someValues']
        ],
    ];
    $variations = $builder->build($config);

    foreach ($variations as $values) {
        echo sprintf('text: %s, number: %d', $values['text'], $values['number']);
        echo PHP_EOL;
    }

```

Result will be exactly the same as from the previous one. Result will be the same for callback defined as '\['range', \[0, 2\]\]'.

Supports cross-referencing between variations:

```
    class DummyClass
    {
        public function someValues($text)
        {
            $values = [
                'first' => [0, 1],
                'second' => [2, 3],
                'third' => [4, 5],
            ];

            return $values[$text];
        }
    }
    $factory = new VariationFactory();
    $builder = new VariationsTreeBuilder($factory);

    $config = [
        'text' => [
            'type' => 'enum',
            'values' => ['first', 'second', 'third'],
        ],
        'number' => [
            'type' => 'callback',
            'callback' => [DummyClass::class, 'someValues', ['@text']],
            'context_dependent' => true
        ],
    ];
    $variations = $builder->build($config);

    foreach ($variations as $values) {
        echo sprintf('text: %s, number: %d', $values['text'], $values['number']);
        echo PHP_EOL;
    }

```

Output will be:

```
    text: first, number: 0
    text: first, number: 1
    text: second, number: 2
    text: second, number: 3
    text: third, number: 4
    text: third, number: 5

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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

2

Last Release

3546d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c3d1a78d51f48df425a29607ea5a340c6d7926517486c9d10683e498292ad3a5?d=identicon)[kozog](/maintainers/kozog)

### Embed Badge

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

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

###  Alternatives

[shaozeming/aliyun-sts

基于阿里云openapi系列接口中STS最新版本的SDK进行封装的composer package

2021.0k1](/packages/shaozeming-aliyun-sts)

PHPackages © 2026

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