src/Leevel/Seccode/Seccode.php
protected function autoCode(int $size, string $autoType = self::ALPHA_UPPERCASE): void
    {
        if ($size < 1) {
            $e = sprintf('Code must be greater than %d.', 0);

            throw new InvalidArgumentException($e);
        }

        if (!in_array($autoType, $this->getAllowedAutoType(), true)) {
            $e = sprintf(
                'Code type must be these %s.',
                implode(',', $this->getAllowedAutoType())
            );

            throw new InvalidArgumentException($e);
        }

        $randMethod = 'Leevel\\Support\\Str\\rand_'.$autoType;

        $this->code(fn($randMethod, $size));
    }
protected function autoCode(int $size, string $autoType = self::ALPHA_UPPERCASE): void
    {
        if ($size < 1) {
            $e = sprintf('Code must be greater than %d.', 0);

            throw new InvalidArgumentException($e);
        }

        if (!in_array($autoType, $this->getAllowedAutoType(), true)) {
            $e = sprintf(
                'Code type must be these %s.',
                implode(',', $this->getAllowedAutoType())
            );

            throw new InvalidArgumentException($e);
        }

        $randMethod = 'Leevel\\Support\\Str\\rand_'.$autoType;

        $this->code(fn($randMethod, $size));
    }
自动产生验证码

@param int    $size
@param string $autoType