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

generateWordList() public method

Generate character list for us in generating passwords.
public generateWordList ( ) : string[]
return string[] Character list
    public function generateWordList()
    {
        if ($this->getParameter(self::PARAMETER_WORD_CACHE) !== null) {
            $this->findWordListLength();
            return $this->getParameter(self::PARAMETER_WORD_CACHE);
        }
        $words = explode("\n", \file_get_contents($this->getWordList()));
        $minWordLength = $this->getOptionValue(self::OPTION_MIN_WORD_LENGTH);
        $maxWordLength = $this->getOptionValue(self::OPTION_MAX_WORD_LENGTH);
        foreach ($words as $i => $word) {
            $wordLength = \strlen($word);
            if ($wordLength > $maxWordLength || $wordLength < $minWordLength) {
                unset($words[$i]);
            }
        }
        $words = \array_values($words);
        if (!$words) {
            throw new WordsNotFoundException('No words selected.');
        }
        $this->setParameter(self::PARAMETER_WORD_CACHE, $words);
        $this->findWordListLength();
        return $words;
    }