public function EasyRdf_ParsedUri::__construct in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/ParsedUri.php \EasyRdf_ParsedUri::__construct()
Constructor for creating a new parsed URI
The $uri parameter can either be a string or an associative array with the following keys: scheme, authority, path, query, fragment
Parameters
mixed $uri The URI as a string or an array:
Return value
object EasyRdf_ParsedUri
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ ParsedUri.php, line 69
Class
- EasyRdf_ParsedUri
- A RFC3986 compliant URI parser
Code
public function __construct($uri = null) {
if (is_string($uri)) {
if (preg_match(self::URI_REGEX, $uri, $matches)) {
if (!empty($matches[1])) {
$this->scheme = isset($matches[2]) ? $matches[2] : '';
}
if (!empty($matches[3])) {
$this->authority = isset($matches[4]) ? $matches[4] : '';
}
$this->path = isset($matches[5]) ? $matches[5] : '';
if (!empty($matches[6])) {
$this->query = isset($matches[7]) ? $matches[7] : '';
}
if (!empty($matches[8])) {
$this->fragment = isset($matches[9]) ? $matches[9] : '';
}
}
}
elseif (is_array($uri)) {
$this->scheme = isset($uri['scheme']) ? $uri['scheme'] : null;
$this->authority = isset($uri['authority']) ? $uri['authority'] : null;
$this->path = isset($uri['path']) ? $uri['path'] : null;
$this->query = isset($uri['query']) ? $uri['query'] : null;
$this->fragment = isset($uri['fragment']) ? $uri['fragment'] : null;
}
}