protected static function replacePattern($pattern, $container, $url, $conditional, $remove_conditional)
    {
        if (array_key_exists($pattern, $container)) {
            $replace = (count(self::$parameters[$pattern]) || $conditional) ? '('.$container[$pattern].')' : $container[$pattern];
            if ($conditional) {
                $replace = ($remove_conditional) ? '' : $replace.'?';
                $url = preg_replace('#\{'.$pattern.'\?\}#', $replace, $url);
            } else {
                $url = preg_replace('#\{'.$pattern.'\}#', $replace, $url);
            }
        }
        return $url;
    }