public static function translit($string, $substChar = '?', $trim = true, $removeDuplicates = true)
    {
        // Cast scalars to strings, if non-scalar is given throw an exception
        if (!is_string($string)) {
            if (is_scalar($string)) {
                $string = (string) $string;
            } else {
                $type = gettype($string);
                throw new \InvalidArgumentException(__METHOD__ . "() expects parameter 1 to be string, $type given");
            }
        }

        // Replace language-specific characters
        $string = strtr($string, CharacterMap::get());

        // Replace any leftover non-ASCII characters by the replacement char.
        $string = preg_replace("/[^\\w]/", $substChar, $string);

        if ($trim) {
            $string = trim($string, $substChar);
        }

        if ($removeDuplicates) {
            $string = preg_replace("/\\{$substChar}+/", $substChar, $string);
        }

        return $string;
    }