public static function removeEndingDirectorySeparator($text, $separator = '')
    {
        /*
         * Not a string?
         * Nothing to do
         */
        if (!is_string($text)) {
            return '';
        }

        if (empty($separator)) {
            $separator = DIRECTORY_SEPARATOR;
        }

        $effect = trim($text);

        if (Regex::endsWithDirectorySeparator($effect, $separator)) {
            $effect = mb_substr($effect, 0, mb_strlen($effect) - mb_strlen($separator));
        }

        return $effect;
    }