UriTemplate
in package
Expands URI templates. Userland implementation of PECL uri_template.
Tags
Table of Contents
- $delims : array<string|int, mixed>
- $delimsPct : array<string|int, mixed>
- $operatorHash : array<string|int, mixed>
- $template : string
- $variables : array<string|int, mixed>
- expand() : mixed
- 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
Properties
$delims
private
static array<string|int, mixed>
$delims
= [':', '/', '?', '#', '[', ']', '@', '!', '$', '&', ''', '(', ')', '*', '+', ',', ';', '=']
$delimsPct
private
static array<string|int, mixed>
$delimsPct
= ['%3A', '%2F', '%3F', '%23', '%5B', '%5D', '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C', '%3B', '%3D']
$operatorHash
private
static array<string|int, mixed>
$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]]
$template
private
string
$template
$variables
private
array<string|int, mixed>
$variables
Methods
expand()
public
expand(mixed $template, array<string|int, mixed> $variables) : mixed
Parameters
- $template : mixed
- $variables : array<string|int, mixed>
Return values
mixed —decodeReserved()
Removes percent encoding on reserved characters (used with + and # modifiers).
private
decodeReserved(string $string) : string
Parameters
- $string : string
-
String to fix
Return values
string —expandMatch()
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
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.
Parameters
- $array : array<string|int, mixed>
-
Array to check
Return values
bool —parseExpression()
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