public function __construct($url = NULL)
{
if (is_string($url)) {
$p = @parse_url($url);
// @ - is escalated to exception
if ($p === FALSE) {
throw new Nette\InvalidArgumentException("Malformed or unsupported URI '{$url}'.");
}
$this->scheme = isset($p['scheme']) ? $p['scheme'] : '';
$this->port = isset($p['port']) ? $p['port'] : NULL;
$this->host = isset($p['host']) ? rawurldecode($p['host']) : '';
$this->user = isset($p['user']) ? rawurldecode($p['user']) : '';
$this->password = isset($p['pass']) ? rawurldecode($p['pass']) : '';
$this->setPath(isset($p['path']) ? $p['path'] : '');
$this->setQuery(isset($p['query']) ? $p['query'] : []);
$this->fragment = isset($p['fragment']) ? rawurldecode($p['fragment']) : '';
} elseif ($url instanceof self) {
foreach ($this as $key => $val) {
$this->{$key} = $url->{$key};
}
}
}