Skip to content

petrgrishin/create-matrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

create-matrix

Travis CI

Helper for create matrix

Installation

Add a dependency to your project's composer.json file if you use Composer to manage the dependencies of your project:

{
    "require": {
        "petrgrishin/create-matrix": "~1.0"
    }
}

Usage examples

Create matrix by the variants

$variants = [
    'a' => [1, 2],
    'b' => [10, 20],
];
$matrix = CreateMatrix::byVariants($variants)->getArray();

// result
$matrix = Array
(
    [0] => Array
        (
            [a] => 1
            [b] => 10
        )

    [1] => Array
        (
            [a] => 1
            [b] => 20
        )

    [2] => Array
        (
            [a] => 2
            [b] => 10
        )

    [3] => Array
        (
            [a] => 2
            [b] => 20
        )

)

Create matrix with variant an empty value

$variants = [
    'a' => [1, null],
    'b' => [10, null],
];
$matrix = CreateMatrix::byVariants($variants)->getArray();

// result
$matrix = Array
(
    [0] => Array
        (
            [a] => 1
            [b] => 10
        )

    [1] => Array
        (
            [a] => 1
            [b] => 
        )

    [2] => Array
        (
            [a] => 
            [b] => 10
        )

    [3] => Array
        (
            [a] => 
            [b] => 
        )

)

About

Helper for create matrix

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages