src/ShortCode/Random.php
public static function get($length = 8, $outputFormat = Code::FORMAT_ALNUM)
    {
        static::throwUnlessAcceptable($outputFormat, $length);

        $number = rand(100, 900) . str_replace('.', '', microtime(true));
        $output = self::convertBase($number, self::FORMAT_NUMBER, $outputFormat);

        if(strlen($output) < $length) {
            $output .= substr(str_shuffle($outputFormat.$outputFormat), 0, ($length - strlen($output)));
        }
        if(strlen($output) > $length) {
            $output = substr($output, 0, $length);
        }

        return $output;
    }
public static function get($length = 8, $outputFormat = Code::FORMAT_ALNUM)
    {
        static::throwUnlessAcceptable($outputFormat, $length);

        $number = rand(100, 900) . str_replace('.', '', microtime(true));
        $output = self::convertBase($number, self::FORMAT_NUMBER, $outputFormat);

        if(strlen($output) < $length) {
            $output .= substr(str_shuffle($outputFormat.$outputFormat), 0, ($length - strlen($output)));
        }
        if(strlen($output) > $length) {
            $output = substr($output, 0, $length);
        }

        return $output;
    }
Get a random code of fixed length.

@param int $length  length of code, default 8
@param string $outputFormat One of Code::FORMAT_* constants. Default Code::FORMAT_ALNUM

@return string