public function parseUrl($str)
	{
		if (! is_string($str)) {
			throw new InvalidUrlException('Unexpected type.');
		}
		if ($str === '') {
			throw new InvalidUrlException('Empty URL.');
		}
		if (trim($str, ' ') === '') {
			throw new InvalidUrlException('Empty URL.');
		}
		$components = $this->parseUrlComponents($str);
		$components = array_replace([
			'scheme' => '',
			'host' => '',
			'port' => '',
			'user' => '',
			'pass' => '',
			'path' => '',
			'query' => '',
			'fragment' => ''
		], $components);
		$this->scheme->parseComponent($components['scheme']);
		$this->host->parseComponent($components['host']);
		$this->port->parseComponent(strval($components['port']));
		if (empty($components['user']) && empty($components['pass'])) {
			$this->credentials->username = null;
			$this->credentials->password = null;
		} else {
			$this->credentials->parseComponent($components['user'] . ':' . $components['pass']);
		}
		$this->path->parseComponent($components['path']);
		$this->query->parseComponent($components['query']);
		$this->fragment->parseComponent($components['fragment']);
		return $this;
	}