Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.

Commit d0505bd

Browse files
Simplified algorithm in GroupSeeder
Co-authored-by: Thomas Ritaine <[email protected]>
1 parent b01104b commit d0505bd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/DataFixtures/GroupSeeder.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,16 @@ public function load(ObjectManager $manager)
5656
$group->setSlug(Slug::slugify($name));
5757

5858
// isVisible property. We might need to force the last groups to be visible or not, so that the minimum/maximum amounts are respected.
59-
$isVisible = true;
60-
if ($this->minimumVisibleGroupCount - $visibleGroupCount < 19 - $i // Minimum condition
61-
&& $this->maximumVisibleGroupCount !== $visibleGroupCount) { // Maximum condition
59+
if ($visibleGroupCount < $this->minimumVisibleGroupCount) {
60+
$isVisible = true;
61+
} else if ($visibleGroupCount < $this->maximumVisibleGroupCount) {
6262
$isVisible = $faker->boolean(75);
63+
} else {
64+
$isVisible = false;
6365
}
66+
6467
if ($isVisible) {
65-
++$visibleGroupCount;
68+
$visibleGroupCount++;
6669
}
6770
$group->setIsVisible($isVisible);
6871

0 commit comments

Comments
 (0)