Documentation

UriTemplate
in package

Defines the URI Template syntax and the process for expanding a URI Template into a URI reference.

Tags
link
https://tools.ietf.org/html/rfc6570
link
https://github.com/guzzle/guzzle/blob/6.5/src/UriTemplate.php
author

Ignace Nyamagana Butera nyamsprod@gmail.com

since
6.1.0

Based on GuzzleHttp\UriTemplate class in Guzzle v6.5.

Table of Contents

$defaultVariables  : VariableBag
$template  : Template
__construct()  : mixed
__set_state()  : self
expand()  : UriInterface
getDefaultVariables()  : array<string, string|array>
Returns the default values used to expand the template.
getTemplate()  : string
The template string.
getVariableNames()  : array<string|int, string>
Returns the names of the variables in the template, in order.
withDefaultVariables()  : self
Returns a new instance with the updated default variables.
filterVariables()  : VariableBag
Filters out variables for the given template.

Properties

Methods

__construct()

public __construct(object|string $template[, array<string|int, mixed> $defaultVariables = [] ]) : mixed
Parameters
$template : object|string

a string or an object with the __toString method

$defaultVariables : array<string|int, mixed> = []
Tags
throws
TypeError

if the template is not a string or an object with the __toString method

throws
SyntaxError

if the template syntax is invalid

throws
TemplateCanNotBeExpanded

if the template variables are invalid

Return values
mixed

__set_state()

public static __set_state(array<string|int, mixed> $properties) : self
Parameters
$properties : array<string|int, mixed>
Return values
self

getDefaultVariables()

Returns the default values used to expand the template.

public getDefaultVariables() : array<string, string|array>

The returned list only contains variables whose name is part of the current template.

Return values
array<string, string|array>

getTemplate()

The template string.

public getTemplate() : string
Return values
string

getVariableNames()

Returns the names of the variables in the template, in order.

public getVariableNames() : array<string|int, string>
Return values
array<string|int, string>

withDefaultVariables()

Returns a new instance with the updated default variables.

public withDefaultVariables(array<string|int, mixed> $defaultDefaultVariables) : self

This method MUST retain the state of the current instance, and return an instance that contains the modified default variables.

If present, variables whose name is not part of the current template possible variable names are removed.

Parameters
$defaultDefaultVariables : array<string|int, mixed>
Return values
self

filterVariables()

Filters out variables for the given template.

private filterVariables(array<string, string|string[]> $variables) : VariableBag
Parameters
$variables : array<string, string|string[]>
Return values
VariableBag

Search results