@@ -18,7 +18,7 @@ class Permutations extends Combinatorics {
1818 *
1919 * @var \drupol\phpermutations\Generators\Combinations
2020 */
21- public $ combinations ;
21+ protected $ combinations ;
2222
2323 /**
2424 * Combinatorics constructor.
@@ -36,28 +36,13 @@ public function __construct(array $dataset = array(), $length = NULL) {
3636 /**
3737 * Alias of the get() method.
3838 *
39- * @return \Generator
40- * The prime generator.
41- */
42- public function generator () {
43- return $ this ->get ($ this ->getDataset (), $ this ->getLength ());
44- }
45-
46- /**
47- * The combination generator.
48- *
49- * @param array $dataset
50- * The dataset.
51- * @param int $length
52- * The length.
53- *
5439 * @codingStandardsIgnoreStart
5540 * @return \Generator
5641 * @codingStandardsIgnoreEnd
5742 */
58- protected function get ( array $ dataset , $ length ) {
43+ public function generator ( ) {
5944 foreach ($ this ->combinations ->generator () as $ combination ) {
60- foreach ($ this ->getPermutations ($ combination ) as $ current ) {
45+ foreach ($ this ->get ($ combination ) as $ current ) {
6146 yield $ current ;
6247 }
6348 }
@@ -73,15 +58,15 @@ protected function get(array $dataset, $length) {
7358 * @return \Generator
7459 * @codingStandardsIgnoreEnd
7560 */
76- protected function getPermutations (array $ dataset ) {
61+ protected function get (array $ dataset ) {
7762 foreach ($ dataset as $ key => $ firstItem ) {
7863 $ remaining = $ dataset ;
7964 array_splice ($ remaining , $ key , 1 );
8065 if (count ($ remaining ) === 0 ) {
8166 yield [$ firstItem ];
8267 continue ;
8368 }
84- foreach ($ this ->getPermutations ($ remaining ) as $ permutation ) {
69+ foreach ($ this ->get ($ remaining ) as $ permutation ) {
8570 array_unshift ($ permutation , $ firstItem );
8671 yield $ permutation ;
8772 }
0 commit comments