PHP Class Ergo\Http\Url

See also: http://github.com/pda/phool
Author: Paul Annesley ([email protected])
Show file Open project: 99designs/ergo Class Usage Examples

Public Methods

Method Description
__construct ( string $urlString )
__toString ( ) : string The URL as a string.
construct ( $urlString )
getDefaultPort ( ) : integer The default TCP port for the scheme of the URL
getFragmentString ( ) : string Fragment string (after fragment delimiter '#')
getHost ( ) : string Hostname (without port information) e.g. example.org
getHostRelativeUrl ( ) : string The URL components after the host.
getHostWithPort ( ) : string Host, including port unless it is the default port for the scheme.
getPath ( ) : string Path component (after host, before query string delimiter '?')
getPort ( ) : integer TCP port number, defaults to 80 for HTTP and 443 for HTTPS.
getQueryString ( ) : string Query string (after query delimiter '?', before fragment delimiter '#')
getScheme ( ) : string Scheme, either http or https
getSchemeRelativeUrl ( ) : string The URL components after the scheme
getUrlForFragment ( $fragment ) : Url Builds a url with a different fragment (the part after # in the url)
getUrlForHost ( $host ) : Url Builds a URL with a different host
getUrlForMergedParameters ( array $queryParameters ) Builds a URL with added/merged query parameters
getUrlForParameters ( array $queryParameters )
getUrlForPath ( $path ) : Url Builds a URL with a different path component
getUrlForRelativePath ( $path ) : Url Builds a URL with a path component that is relative to the current one
getUrlForScheme ( $scheme ) : Url Builds a URL with a different scheme
hasDefaultPort ( ) Whether the URL has a default port (i.e. has a scheme)
hasFragmentString ( ) : boolean Whether the URL has a fragment string.
hasHost ( ) : boolean Whether the URL has a host component.
hasPort ( ) Whether the URL has an explicitly specified port.
hasQueryString ( ) : boolean Whether the URL has a query string.
hasScheme ( ) : boolean Whether the URL has a scheme component.
isPortDefault ( ) : boolean Whether the port is the default for the scheme.
relative ( $path )

Private Methods

Method Description
_joinPathComponents ( $path ) Join path/querystring/fragment components together

Method Details

__construct() public method

public __construct ( string $urlString )
$urlString string

__toString() public method

The URL as a string.
public __toString ( ) : string
return string

construct() public static method

public static construct ( $urlString )

getDefaultPort() public method

The default TCP port for the scheme of the URL
public getDefaultPort ( ) : integer
return integer or null

getFragmentString() public method

Fragment string (after fragment delimiter '#')
public getFragmentString ( ) : string
return string

getHost() public method

Hostname (without port information) e.g. example.org
public getHost ( ) : string
return string

getHostRelativeUrl() public method

The URL components after the host.
public getHostRelativeUrl ( ) : string
return string

getHostWithPort() public method

Host, including port unless it is the default port for the scheme.
public getHostWithPort ( ) : string
return string

getPath() public method

Path component (after host, before query string delimiter '?')
public getPath ( ) : string
return string

getPort() public method

TCP port number, defaults to 80 for HTTP and 443 for HTTPS.
public getPort ( ) : integer
return integer

getQueryString() public method

Query string (after query delimiter '?', before fragment delimiter '#')
public getQueryString ( ) : string
return string

getScheme() public method

Scheme, either http or https
public getScheme ( ) : string
return string

getSchemeRelativeUrl() public method

The URL components after the scheme
public getSchemeRelativeUrl ( ) : string
return string

getUrlForFragment() public method

Builds a url with a different fragment (the part after # in the url)
public getUrlForFragment ( $fragment ) : Url
return Url

getUrlForHost() public method

Builds a URL with a different host
public getUrlForHost ( $host ) : Url
return Url

getUrlForMergedParameters() public method

Builds a URL with added/merged query parameters
public getUrlForMergedParameters ( array $queryParameters )
$queryParameters array

getUrlForParameters() public method

public getUrlForParameters ( array $queryParameters )
$queryParameters array

getUrlForPath() public method

Builds a URL with a different path component
public getUrlForPath ( $path ) : Url
return Url

getUrlForRelativePath() public method

Builds a URL with a path component that is relative to the current one
public getUrlForRelativePath ( $path ) : Url
return Url

getUrlForScheme() public method

Builds a URL with a different scheme
public getUrlForScheme ( $scheme ) : Url
return Url

hasDefaultPort() public method

Whether the URL has a default port (i.e. has a scheme)
public hasDefaultPort ( )

hasFragmentString() public method

Whether the URL has a fragment string.
public hasFragmentString ( ) : boolean
return boolean

hasHost() public method

Whether the URL has a host component.
public hasHost ( ) : boolean
return boolean

hasPort() public method

Whether the URL has an explicitly specified port.
public hasPort ( )

hasQueryString() public method

Whether the URL has a query string.
public hasQueryString ( ) : boolean
return boolean

hasScheme() public method

Whether the URL has a scheme component.
public hasScheme ( ) : boolean
return boolean

isPortDefault() public method

Whether the port is the default for the scheme.
public isPortDefault ( ) : boolean
return boolean

relative() public method

public relative ( $path )