for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace drupol\phpermutations\Generators;
/**
* Class Permutations.
*
* @package drupol\phpermutations\Generators
*/
class Permutations {
* @param $data
* @return \Generator
public function generator($data) {
if (count($data) <= 1) {
yield $data;
} else {
foreach (range(0, count($data) - 1) as $i) {
foreach ($this->generator(array_slice($data, 1)) as $item) {
yield array_merge(array_slice($item, 0, $i), array_slice($data, 0, 1), array_slice($item, $i));
}