Documentation

Expression
in package

Table of Contents

OPERATOR_HASH_LOOKUP  = ['' => ['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]]
Processing behavior according to the expression type operator.
REGEXP_EXPRESSION  = '/^\{ (?: (?<operator>[\.\/;\?&\=,\!@\|\+#])? (?<variables>[^\}]*) ) \}$/x'
Expression regular expression pattern.
RESERVED_OPERATOR  = '=,!@|'
Reserved Operator characters.
$expressionString  : string
$joiner  : string
$operator  : string
$variableNames  : array<string|int, mixed>
$varSpecifiers  : array<string|int, mixed>
__set_state()  : self
{@inheritDoc}
createFromString()  : self
expand()  : string
toString()  : string
Returns the expression string representation.
variableNames()  : array<string|int, string>
__construct()  : mixed
decodeReserved()  : string
Removes percent encoding on reserved characters (used with + and # modifiers).
inject()  : array{0: string, 1: bool}
isAssoc()  : bool
Determines if an array is associative.
replace()  : string
Replaces an expression with the given variables.
replaceList()  : array{0: string, 1: bool}
Expands an expression using a list of values.
replaceString()  : array{0: string, 1: bool}
Expands an expression using a string value.
setExpressionString()  : string
setVariableNames()  : array<string|int, string>

Constants

OPERATOR_HASH_LOOKUP

Processing behavior according to the expression type operator.

private mixed OPERATOR_HASH_LOOKUP = ['' => ['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]]
Tags
link
https://tools.ietf.org/html/rfc6570#appendix-A

Properties

$expressionString

private string $expressionString

$variableNames

private array<string|int, mixed> $variableNames

$varSpecifiers

private array<string|int, mixed> $varSpecifiers

Methods

__set_state()

{@inheritDoc}

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

createFromString()

public static createFromString(string $expression) : self
Parameters
$expression : string
Tags
throws
SyntaxError

if the expression is invalid

throws
SyntaxError

if the operator used in the expression is invalid

throws
SyntaxError

if the variable specifiers is invalid

Return values
self

toString()

Returns the expression string representation.

public toString() : string
Return values
string

variableNames()

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

__construct()

private __construct(string $operator, VarSpecifier ...$varSpecifiers) : mixed
Parameters
$operator : string
$varSpecifiers : VarSpecifier
Return values
mixed

decodeReserved()

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

private decodeReserved(string $str) : string
Parameters
$str : string
Return values
string

inject()

private inject(string|array<string|int, string> $value, VarSpecifier $varSpec, bool $useQuery) : array{0: string, 1: bool}
Parameters
$value : string|array<string|int, string>
$varSpec : VarSpecifier
$useQuery : bool
Return values
array{0: string, 1: bool}

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 trade-off 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>
Return values
bool

replaceList()

Expands an expression using a list of values.

private replaceList(array<string|int, string> $value, VarSpecifier $varSpec, bool $useQuery) : array{0: string, 1: bool}
Parameters
$value : array<string|int, string>
$varSpec : VarSpecifier
$useQuery : bool
Tags
throws
TemplateCanNotBeExpanded

if the variables is an array and a ":" modifier needs to be applied

Return values
array{0: string, 1: bool}

replaceString()

Expands an expression using a string value.

private replaceString(string $value, VarSpecifier $varSpec, bool $useQuery) : array{0: string, 1: bool}
Parameters
$value : string
$varSpec : VarSpecifier
$useQuery : bool
Return values
array{0: string, 1: bool}

setExpressionString()

private setExpressionString() : string
Return values
string

setVariableNames()

private setVariableNames() : array<string|int, string>
Return values
array<string|int, string>

Search results