public static function deleteTrailing($needle, $haystack)
    {
        $pattern = '#(' . self::pregQuote($needle, '#') . ')+$#';
        $result = preg_replace($pattern, '', $haystack);

        return $result;
    }