Skip to content

Commit 2e9447e

Browse files
author
antoine
committed
Random visual in factory
1 parent 8ab68c4 commit 2e9447e

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

database/factories/BookFactory.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
class BookFactory extends Factory
88
{
9-
private static int $VISUAL_INDEX = 0;
10-
119
private static array $VISUALS = [
1210
'229/9782070585229',
1311
'904/9782070624904',
@@ -115,16 +113,10 @@ public function definition()
115113

116114
private function getVisual(string $size = 'L'): string
117115
{
118-
$visual = sprintf(
116+
return sprintf(
119117
'https://images.epagine.fr/%s_1_%s.jpg',
120-
self::$VISUALS[self::$VISUAL_INDEX],
118+
self::$VISUALS[array_rand(self::$VISUALS)],
121119
['S' => 'v', 'M' => 'm', 'L' => '75'][$size] ?? '75'
122120
);
123-
124-
if (++self::$VISUAL_INDEX >= count(self::$VISUALS)) {
125-
self::$VISUAL_INDEX = 0;
126-
}
127-
128-
return $visual;
129121
}
130122
}

0 commit comments

Comments
 (0)