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

Commit

Permalink
Fixed a potential issue on rand usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel authored and weierophinney committed Nov 23, 2015
1 parent 8b2d22b commit 5561ef8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/AbstractWord.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,12 @@ protected function generateWord()
$vowels = $this->useNumbers ? static::$VN : static::$V;
$consonants = $this->useNumbers ? static::$CN : static::$C;

$totIndexCon = count($consonants) - 1;
$totIndexVow = count($vowels) - 1;
for ($i=0; $i < $wordLen; $i = $i + 2) {
// generate word with mix of vowels and consonants
$consonant = $consonants[array_rand($consonants)];
$vowel = $vowels[array_rand($vowels)];
$consonant = $consonants[Rand::getInteger(0, $totIndexCon, true)];
$vowel = $vowels[Rand::getInteger(0, $totIndexVow, true)];
$word .= $consonant . $vowel;
}

Expand Down

0 comments on commit 5561ef8

Please sign in to comment.