diff options
Diffstat (limited to 'apps/files_external/3rdparty/aws-sdk-php/Guzzle/Parser/UriTemplate/UriTemplate.php')
-rw-r--r-- | apps/files_external/3rdparty/aws-sdk-php/Guzzle/Parser/UriTemplate/UriTemplate.php | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Parser/UriTemplate/UriTemplate.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Parser/UriTemplate/UriTemplate.php index 2044810b5d4..0df032f0ff8 100644 --- a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Parser/UriTemplate/UriTemplate.php +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Parser/UriTemplate/UriTemplate.php @@ -9,6 +9,8 @@ namespace Guzzle\Parser\UriTemplate; */ class UriTemplate implements UriTemplateInterface { + const DEFAULT_PATTERN = '/\{([^\}]+)\}/'; + /** @var string URI template */ private $template; @@ -16,7 +18,7 @@ class UriTemplate implements UriTemplateInterface private $variables; /** @var string Regex used to parse expressions */ - private static $regex = '/\{([^\}]+)\}/'; + private $regex = self::DEFAULT_PATTERN; /** @var array Hash for quick operator lookups */ private static $operatorHash = array( @@ -36,15 +38,24 @@ class UriTemplate implements UriTemplateInterface public function expand($template, array $variables) { + if ($this->regex == self::DEFAULT_PATTERN && false === strpos($template, '{')) { + return $template; + } + $this->template = $template; $this->variables = $variables; - // Check to ensure that the preg_* function is needed - if (false === strpos($this->template, '{')) { - return $this->template; - } + return preg_replace_callback($this->regex, array($this, 'expandMatch'), $this->template); + } - return preg_replace_callback(self::$regex, array($this, 'expandMatch'), $this->template); + /** + * Set the regex patten used to expand URI templates + * + * @param string $regexPattern + */ + public function setRegex($regexPattern) + { + $this->regex = $regexPattern; } /** |