public function generate()
    {
        $alphabet = '';

        if (strpos($this->available_sets, 'l') !== false) {
            $alphabet .= $this->lowercase;
        }

        if (strpos($this->available_sets, 'u') !== false) {
            $alphabet .= $this->uppercase;
        }

        if (strpos($this->available_sets, 'd') !== false) {
            $alphabet .= $this->numbers;
        }

        if (strpos($this->available_sets, 's') !== false) {
            $alphabet .= $this->special_chars;
        }

        $alphamax = strlen($alphabet) - 1;

        if ($alphamax < 1) {
            throw new PasswordException('Invalid alphabet');
        }

        $this->password = '';

        for ($i = 0; $i < $this->length; ++$i) {
            $this->password .= $alphabet[random_int(0, $alphamax)];
        }

        return $this->password;
    }