public function __construct($uriString)
{
if (!is_string($uriString)) {
throw new \InvalidArgumentException('The URI must be a valid string.', 1176550571);
}
$parseUrlException = null;
try {
$uriParts = Unicode\Functions::parse_url($uriString);
} catch (FlowError\Exception $exception) {
$parseUrlException = $exception;
}
if (is_array($uriParts)) {
$this->scheme = isset($uriParts['scheme']) ? $uriParts['scheme'] : null;
$this->username = isset($uriParts['user']) ? $uriParts['user'] : null;
$this->password = isset($uriParts['pass']) ? $uriParts['pass'] : null;
$this->host = isset($uriParts['host']) ? $uriParts['host'] : null;
$this->port = isset($uriParts['port']) ? $uriParts['port'] : null;
if ($this->port === null) {
switch ($this->scheme) {
case 'http':
$this->port = 80;
break;
case 'https':
$this->port = 443;
break;
}
}
$this->path = isset($uriParts['path']) ? $uriParts['path'] : null;
if (isset($uriParts['query'])) {
$this->setQuery($uriParts['query']);
}
$this->fragment = isset($uriParts['fragment']) ? $uriParts['fragment'] : null;
} else {
throw new \InvalidArgumentException('The given URI "' . $uriString . '" is not a valid one.', 1351594202, $parseUrlException);
}
}