public static function randomString($length, $method = 'alnum')
    {
        $types = array(
            'alpha' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
            'alnum' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
            'numeric' => '0123456789'
        );

        if (isset($types[$method])) {
            $dictionary = $types[$method];
        } else {
            throw new UnexpectedValueException(sprintf('Unsupported dictionary type provided "%s"', $method));
        }

        $output = '';

        for ($i = 0; $i < $length; $i++) {
            $output .= substr($dictionary, mt_rand(0, strlen($dictionary) -1), 1);
        }

        return $output;
    }