protected function parse($urn) { // URNs are case insensitive $urn = strtolower((string) $urn); parent::parse($urn); // must have an urn scheme and path part if ($this->scheme != 'urn' || empty($this->path)) { throw new InvalidArgumentException('Invalid urn syntax'); } // parse $this->nid = strstr($this->path, ':', true); $this->nss = substr(strstr($this->path, ':'), 1); }
protected function parse($url) { $url = (string) $url; // append http scheme for urls starting with //. Normally // means that // we use the scheme from the base url but in this context there is no // base url available so we assume http if (substr($url, 0, 2) == '//') { $url = 'http:' . $url; } parent::parse($url); // we need at least an scheme and host if (empty($this->scheme) || empty($this->host)) { throw new InvalidArgumentException('Invalid url syntax'); } // check port if available if ($this->port !== null) { if ($this->port < 1 || $this->port > 0xffff) { throw new InvalidArgumentException('Invalid port range'); } } }