public static function substringBeforeLast($str, $separator)
    {
        if ((true === self::isEmpty($str))
            || (true === self::isEmpty($separator))
        ) {
            return $str;
        }

        $pos = self::lastIndexOf($str, $separator);

        if (self::INDEX_NOT_FOUND === $pos) {
            return $str;
        }

        return self::substring($str, 0, $pos);
    }