public function generatePassphrase($num_words = 4)
    {
        if (count($this->dictionary) < $num_words)
        {
            throw new UnderflowException(
                "Not enough words loaded to generate a passphrase of $num_words words"
            );
        }

        $words = array();
        $attempt = 0;
        while (count($words) < $num_words)
        {
            ++$attempt;
            $s = random_int(0, count($this->dictionary) - 1);
            $word = $this->dictionary[$s];
            if (!in_array($word, $words) || $attempt > 4 * $num_words)
                $words[] = $word;
        }
        return implode(" ", $words);
    }
public function generatePassphrase($num_words = 4)
    {
        if (count($this->dictionary) < $num_words)
        {
            throw new UnderflowException(
                "Not enough words loaded to generate a passphrase of $num_words words"
            );
        }

        $words = array();
        $attempt = 0;
        while (count($words) < $num_words)
        {
            ++$attempt;
            $s = random_int(0, count($this->dictionary) - 1);
            $word = $this->dictionary[$s];
            if (!in_array($word, $words) || $attempt > 4 * $num_words)
                $words[] = $word;
        }
        return implode(" ", $words);
    }
public function generatePassphrase ( $ num_words = 4 ) { if ( count ( $ this -> dictionary ) < $ num_words ) { throw new UnderflowException ( "Not enough words loaded to generate a passphrase of $num_words words" ) ; } $ words = array ( ) ; $ attempt = 0 ; while ( count ( $ words ) < $ num_words ) { ++ $ attempt ; $ s = random_int ( 0 , count ( $ this -> dictionary ) - 1 ) ; $ word = $ this -> dictionary [ $ s ] ; if ( ! in_array ( $ word , $ words ) || $ attempt > 4 * $ num_words ) $ words [ ] = $ word ; } return implode ( " " , $ words ) ; }
Generate a passphrase of the specified amount of words
@param int $num_words The number of words in the passphase
@retuern string The generated passprase
@throws UnderflowException If no or not enough words have been loaded
Generate a passphrase of the specified amount of words