UriTemplate
in package
implements
UriTemplateInterface
Expands URI templates using an array of variables
Tags
Table of Contents
Interfaces
- UriTemplateInterface
- Expands URI templates using an array of variables
Constants
- DEFAULT_PATTERN = '/\{([^\}]+)\}/'
Properties
- $delims : array<string|int, mixed>
- $delimsPct : array<string|int, mixed>
- $operatorHash : array<string|int, mixed>
- $regex : string
- $template : string
- $variables : array<string|int, mixed>
Methods
- expand() : string
- Expand the URI template using the supplied variables
- setRegex() : mixed
- Set the regex patten used to expand URI templates
- decodeReserved() : string
- Removes percent encoding on reserved characters (used with + and # modifiers)
- expandMatch() : string
- Process an expansion
- isAssoc() : bool
- Determines if an array is associative
- parseExpression() : array<string|int, mixed>
- Parse an expression into parts
Constants
DEFAULT_PATTERN
public
mixed
DEFAULT_PATTERN
= '/\{([^\}]+)\}/'
Properties
$delims
private
static array<string|int, mixed>
$delims
= array(':', '/', '?', '#', '[', ']', '@', '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=')
Delimiters
$delimsPct
private
static array<string|int, mixed>
$delimsPct
= array('%3A', '%2F', '%3F', '%23', '%5B', '%5D', '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C', '%3B', '%3D')
Percent encoded delimiters
$operatorHash
private
static array<string|int, mixed>
$operatorHash
= array('+' => true, '#' => true, '.' => true, '/' => true, ';' => true, '?' => true, '&' => true)
Hash for quick operator lookups
$regex
private
string
$regex
= self::DEFAULT_PATTERN
Regex used to parse expressions
$template
private
string
$template
URI template
$variables
private
array<string|int, mixed>
$variables
Variables to use in the template expansion
Methods
expand()
Expand the URI template using the supplied variables
public
expand(mixed $template, array<string|int, mixed> $variables) : string
Parameters
- $template : mixed
-
URI Template to expand
- $variables : array<string|int, mixed>
-
Variables to use with the expansion
Return values
string —Returns the expanded template
setRegex()
Set the regex patten used to expand URI templates
public
setRegex(string $regexPattern) : mixed
Parameters
- $regexPattern : string
decodeReserved()
Removes percent encoding on reserved characters (used with + and # modifiers)
private
decodeReserved(string $string) : string
Parameters
- $string : string
-
String to fix
Return values
stringexpandMatch()
Process an expansion
private
expandMatch(array<string|int, mixed> $matches) : string
Parameters
- $matches : array<string|int, mixed>
-
Matches met in the preg_replace_callback
Return values
string —Returns the replacement string
isAssoc()
Determines if an array is associative
private
isAssoc(array<string|int, mixed> $array) : bool
Parameters
- $array : array<string|int, mixed>
-
Array to check
Return values
boolparseExpression()
Parse an expression into parts
private
parseExpression(string $expression) : array<string|int, mixed>
Parameters
- $expression : string
-
Expression to parse
Return values
array<string|int, mixed> —Returns an associative array of parts