Expands URI templates. Userland implementation of PECL uri_template.

CloneableInstantiable
Methods
public expand( $template, array $variables)
Properties
private static $delims = [':', '/', '?', '#', '[', ']', '@', '!', '$', '&', ''', '(', ')', '*', '+', ',', ';', '=']
 
  • var array Delimiters
private static $delimsPct = ['%3A', '%2F', '%3F', '%23', '%5B', '%5D', '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C', '%3B', '%3D']
 
  • var array Percent encoded delimiters
private static $operatorHash = ['' => ['prefix' => '', 'joiner' => ',', 'query' => false], '+' => ['prefix' => '', 'joiner' => ',', 'query' => false], '#' => ['prefix' => '#', 'joiner' => ',', 'query' => false], '.' => ['prefix' => '.', 'joiner' => '.', 'query' => false], '/' => ['prefix' => '/', 'joiner' => '/', 'query' => false], ';' => ['prefix' => ';', 'joiner' => ';', 'query' => true], '?' => ['prefix' => '?', 'joiner' => '&', 'query' => true], '&' => ['prefix' => '&', 'joiner' => '&', 'query' => true]]
 
  • var array Hash for quick operator lookups
private $template
 
  • var string URI template
private $variables
 
  • var array Variables to use in the template expansion
Methods
private decodeReserved( $string)
 

Removes percent encoding on reserved characters (used with + and #
modifiers).

  • return string
private expandMatch(array $matches)
 

Process an expansion

  • return string Returns the replacement string
private isAssoc(array $array)
 

Determines if an array is associative.

This makes the assumption that input arrays are sequences or hashes.
This assumption is a tradeoff for accuracy in favor of speed, but it
should work in almost every case where input is supplied for a URI
template.

  • return bool
private parseExpression( $expression)
 

Parse an expression into parts

  • return array Returns an associative array of parts
Properties
private static $delims = [':', '/', '?', '#', '[', ']', '@', '!', '$', '&', ''', '(', ')', '*', '+', ',', ';', '=']
 
  • var array Delimiters
private static $delimsPct = ['%3A', '%2F', '%3F', '%23', '%5B', '%5D', '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C', '%3B', '%3D']
 
  • var array Percent encoded delimiters
private static $operatorHash = ['' => ['prefix' => '', 'joiner' => ',', 'query' => false], '+' => ['prefix' => '', 'joiner' => ',', 'query' => false], '#' => ['prefix' => '#', 'joiner' => ',', 'query' => false], '.' => ['prefix' => '.', 'joiner' => '.', 'query' => false], '/' => ['prefix' => '/', 'joiner' => '/', 'query' => false], ';' => ['prefix' => ';', 'joiner' => ';', 'query' => true], '?' => ['prefix' => '?', 'joiner' => '&', 'query' => true], '&' => ['prefix' => '&', 'joiner' => '&', 'query' => true]]
 
  • var array Hash for quick operator lookups
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only