private function UriTemplate::parseExpression in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/guzzle/src/UriTemplate.php \GuzzleHttp\UriTemplate::parseExpression()
Parse an expression into parts
Parameters
string $expression Expression to parse:
Return value
array Returns an associative array of parts
1 call to UriTemplate::parseExpression()
- UriTemplate::expandMatch in vendor/
guzzlehttp/ guzzle/ src/ UriTemplate.php - Process an expansion
File
- vendor/
guzzlehttp/ guzzle/ src/ UriTemplate.php, line 61
Class
- UriTemplate
- Expands URI templates. Userland implementation of PECL uri_template.
Namespace
GuzzleHttpCode
private function parseExpression($expression) {
$result = array();
if (isset(self::$operatorHash[$expression[0]])) {
$result['operator'] = $expression[0];
$expression = substr($expression, 1);
}
else {
$result['operator'] = '';
}
foreach (explode(',', $expression) as $value) {
$value = trim($value);
$varspec = array();
if ($colonPos = strpos($value, ':')) {
$varspec['value'] = substr($value, 0, $colonPos);
$varspec['modifier'] = ':';
$varspec['position'] = (int) substr($value, $colonPos + 1);
}
elseif (substr($value, -1) == '*') {
$varspec['modifier'] = '*';
$varspec['value'] = substr($value, 0, -1);
}
else {
$varspec['value'] = (string) $value;
$varspec['modifier'] = '';
}
$result['values'][] = $varspec;
}
return $result;
}