Hackzilla\PasswordGenerator\Generator\HumanPasswordGenerator::randomWord PHP Method

randomWord() public method

public randomWord ( null | integer $minLength = null, null | integer $maxLength = null ) : string
$minLength null | integer
$maxLength null | integer
return string
    public function randomWord($minLength = null, $maxLength = null)
    {
        if (is_null($minLength)) {
            $minLength = $this->getMinWordLength();
        }
        if (is_null($maxLength)) {
            $maxLength = $this->getMaxWordLength();
        }
        $wordList = $this->generateWordListSubset($minLength, $maxLength);
        $words = \count($wordList);
        if (!$words) {
            throw new NotEnoughWordsException(sprintf('No words with a length between %d and %d', $minLength, $maxLength));
        }
        return $wordList[$this->randomInteger(0, $words - 1)];
    }