Download the PHP package dseguy/data-combinator without Composer

On this page you can find all versions of the php package dseguy/data-combinator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package data-combinator

Data Combinator for PHP

When you want to list all possible combinations of various lists of data.

I.e., from to

This component allows you to create large dataset by combining each possible values with the others.

Applications

Installation

With Composer, do the timeless

Simple example

This generates all combinaisons for 1,2,3 with 4,5,6. A total of 9 array.

APIs

Common-behaviors

Public methods are called with at least two arguments ; the name of the value, and the actual value or a generator for that value.

Each value name is a string, or null. When the name is null, automatic id is generated, starting from 0 (a la PHP).

Index for arrays may be provided with a string, which will be turned into an array index by PHP. Using null and Matrix::TYPE_ARRAY has the same effect as using Matrix::TYPE_LIST. Using Matrix::TYPE_LIST with named values is legit : the names will be dropped at generation time, yet, they provide some readability at configuration time.

It is possible to overwrite a previously set property by adding it again.

It is recommended to avoid using any other format beside string, integers in strings and null.

addConstant

This adds a unique value to the Matrix. No repetition with this one. Note that the value might be an array.

See also addCopy() for cloning objects.

generate

Returns a generator for usage with foreach() structures.

The generator will return the same values as the toArray() method, but yielded, one by one. After a full generation, the generate() method will yield again the same values, as per cache.

AddSet

This adds a list of values to the Matrix. Each value will be repeated once. Provide an array of arrays, to combine those arrays.

addLambda

This method adds a closure, a callback or an arrow function as a value. The closure will be called for each item to generate a new value.

The lambda may be constant or dynamic. The first one is calculated once, then always the same (for example, today's date). The second one is calculated each time, and may yield different value (for example, rand() value, or lambda that is dependent on previously generated values).

The closure receives an (array) argument with all the previously created values. That way, it may create a new value, based on previously generated values. That array is filled in the order of addition to the Matrix : in particular, this means that all values are not always available, since some of them may still be pending. Also, values added as 'alias', are processed last, and are not available.

The provided argument is an array. The type of its values are the type of values added to the Matrix. For sub-matrices, it may be another array or an object, depending on configuration.

When using a closure or an arrow function, it is possible to access a unique Identifier with the $this->uniqueId property. The uniqueId is an int, starting at 1, and incremented each usage.

addPermute

Uses the list as one argument, and generates all possible permutations of the values in it.

addCombine

Uses the list as one set, and generates all possible combinaisons of them, from none (empty array) to all of them.

addCopy

While addConstant() makes a value copy of the constant, addCopy clones the input object each time. They will look identical, at generation time, but are actually distinct objects.

addMatrix

Adding a Matrix to another is the way to nest matrices. It also allows the creation of objects through the combining process.

Matrices have 2 options :

addAlias

Reuse a previously generated value in another slot of the generated data. This is useful when the same value has to be set at two (or more) slots.

Aliases may be added in any order : it is possible to call an alias created in a sub-matrix from the top-matrix, or vice-versa.

Aliases are processed as the last elements in a Matrix. They might not be available in a Lambda call, which will always happen before.

addSequence

Generates sequential data, from min to max, optionally updated by a closure.

setClass

By default, the matrix generates values of type array. This is the most versatile format.

It is possible to turn those arrays into objects, by giving it a class, or into a list (automatically indexed array) by using the Matrix::TYPE_LIST constant. It is possible to force the default type with the Matrix::TYPE_ARRAY constant.

The object is created with an instanciation without arguments. Then, public properties are set by public access. Private and protected properties are omitted; missing values are left untouched; extra values are omitted too.

You may also get a stdClass object by using its fully qualified name. Then, all passed values will be turned into a property.

count

Counts the number of elements to be produced.

toArray

Returns all the possible combinaisons as an array

FAQ

How to shuffle the results?

Use the toArray() method, and apply the PHP native shuffle() function on it.

How to limit the results?

Use foreach() with the generate() method, and count the number of element needed. Then, break when all the needed results were yielded.


All versions of data-combinator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dseguy/data-combinator contains the following files

Loading the files please wait ....