Skip to content

Commit f705536

Browse files
committed
Fix variable names
1 parent e722efb commit f705536

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/Collection/CollectionTrait.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -692,43 +692,39 @@ public function cartesianProduct(callable $operation = null, callable $filter =
692692
return new Collection([]);
693693
}
694694

695-
// contains each array of the collection
696-
$values = [];
697-
// contains the keys of each array
698-
$valuesKeys = [];
699-
// contains the number of elements of each array
700-
$counts = [];
695+
$collectionArrays = [];
696+
$collectionArraysKeys = [];
697+
$collectionArraysCounts = [];
701698

702699
foreach ($this as $value) {
703-
// fail if any of the values is a multidimensional array
704700
if (count($value) !== count($value, COUNT_RECURSIVE)) {
705701
throw new LogicException('Cannot find the cartesian product of a multidimensional array');
706702
}
707703

708-
$valuesKeys[] = array_keys($value);
709-
$counts[] = count($value);
710-
$values[] = $value;
704+
$collectionArraysKeys[] = array_keys($value);
705+
$collectionArraysCounts[] = count($value);
706+
$collectionArrays[] = $value;
711707
}
712708

713709
$result = [];
714-
$lastIndex = count($values) - 1;
710+
$lastIndex = count($collectionArrays) - 1;
715711
// holds the indexes of the arrays that generate the current combination
716712
$currentIndexes = array_fill(0, $lastIndex + 1, 0);
717713

718714
$changeIndex = $lastIndex;
719715

720-
while (!($changeIndex === 0 && $currentIndexes[0] === $counts[0])) {
716+
while (!($changeIndex === 0 && $currentIndexes[0] === $collectionArraysCounts[0])) {
721717
$currentCombination = array_map(function ($value, $keys, $index) {
722718
return $value[$keys[$index]];
723-
}, $values, $valuesKeys, $currentIndexes);
719+
}, $collectionArrays, $collectionArraysKeys, $currentIndexes);
724720

725721
if ($filter === null || call_user_func_array($filter, $currentCombination)) {
726722
$result[] = ($operation === null) ? $currentCombination : call_user_func_array($operation, $currentCombination);
727723
}
728724

729725
$currentIndexes[$lastIndex]++;
730726

731-
for ($changeIndex = $lastIndex; $currentIndexes[$changeIndex] === $counts[$changeIndex] && $changeIndex > 0; $changeIndex--) {
727+
for ($changeIndex = $lastIndex; $currentIndexes[$changeIndex] === $collectionArraysCounts[$changeIndex] && $changeIndex > 0; $changeIndex--) {
732728
$currentIndexes[$changeIndex] = 0;
733729
$currentIndexes[$changeIndex - 1]++;
734730
}

0 commit comments

Comments
 (0)