Newscoop\Random::getRandomString PHP Method

getRandomString() public method

Generate random string
public getRandomString ( integer $length ) : string
$length integer
return string
    public function getRandomString($length)
    {
        if (empty($length)) {
            throw new \InvalidArgumentException("Length can't be empty.");
        }
        $random = array();
        for ($i = 0; $i < $length; $i++) {
            $random[] = $this->chars[mt_rand(0, $this->chars_count - 1)];
        }
        return implode('', $random);
    }