classes/Url.php
protected function set($url)
    {
        $parts = parse_url($url);
        if (!$parts) {
            throw new \InvalidArgumentException('URL malformed');
        }

        $this->scheme   = isset($parts['scheme']) ? strtolower($parts['scheme']) : '';
        $this->username = $parts['user'] ?? '';
        $this->password = $parts['pass'] ?? '';
        $this->host     = isset($parts['host']) ? strtolower($parts['host']) : '';
        $this->port     = isset($parts['port']) ? intval($parts['port']) : null;
        $this->path     = $parts['path'] ?? '';
        $this->query    = $parts['query'] ?? '';
        $this->fragment = $parts['fragment'] ?? '';
    }
protected function set($url)
    {
        $parts = parse_url($url);
        if (!$parts) {
            throw new \InvalidArgumentException('URL malformed');
        }

        $this->scheme   = isset($parts['scheme']) ? strtolower($parts['scheme']) : '';
        $this->username = $parts['user'] ?? '';
        $this->password = $parts['pass'] ?? '';
        $this->host     = isset($parts['host']) ? strtolower($parts['host']) : '';
        $this->port     = isset($parts['port']) ? intval($parts['port']) : null;
        $this->path     = $parts['path'] ?? '';
        $this->query    = $parts['query'] ?? '';
        $this->fragment = $parts['fragment'] ?? '';
    }
protected function set ( $ url ) { $ parts = parse_url ( $ url ) ; if ( ! $ parts ) { throw new \ InvalidArgumentException ( 'URL malformed' ) ; } $ this -> scheme = isset ( $ parts [ 'scheme' ] ) ? strtolower ( $ parts [ 'scheme' ] ) : '' ; $ this -> username = $ parts [ 'user' ] ?? '' ; $ this -> password = $ parts [ 'pass' ] ?? '' ; $ this -> host = isset ( $ parts [ 'host' ] ) ? strtolower ( $ parts [ 'host' ] ) : '' ; $ this -> port = isset ( $ parts [ 'port' ] ) ? intval ( $ parts [ 'port' ] ) : null ; $ this -> path = $ parts [ 'path' ] ?? '' ; $ this -> query = $ parts [ 'query' ] ?? '' ; $ this -> fragment = $ parts [ 'fragment' ] ?? '' ; }
Set URL as string

@param string $url
Set URL as string