Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 5561ef8

Browse files
ezimuelweierophinney
authored andcommitted
Fixed a potential issue on rand usage
1 parent 8b2d22b commit 5561ef8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/AbstractWord.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,12 @@ protected function generateWord()
309309
$vowels = $this->useNumbers ? static::$VN : static::$V;
310310
$consonants = $this->useNumbers ? static::$CN : static::$C;
311311

312+
$totIndexCon = count($consonants) - 1;
313+
$totIndexVow = count($vowels) - 1;
312314
for ($i=0; $i < $wordLen; $i = $i + 2) {
313315
// generate word with mix of vowels and consonants
314-
$consonant = $consonants[array_rand($consonants)];
315-
$vowel = $vowels[array_rand($vowels)];
316+
$consonant = $consonants[Rand::getInteger(0, $totIndexCon, true)];
317+
$vowel = $vowels[Rand::getInteger(0, $totIndexVow, true)];
316318
$word .= $consonant . $vowel;
317319
}
318320

0 commit comments

Comments
 (0)