class Uri extends AbstractUri (View source)

Uri Class

This class parses a URI and provides a common interface for the Windwalker framework to access and manipulate a URI.

This class is a fork from Joomla Uri.

Constants

SCHEME_HTTP

SCHEME_HTTPS

Methods

__construct(string $uri = null)

Constructor.

string
__toString()

Magic method to get the string representation of the URI object.

string
toString(array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment'))

Returns full uri string.

boolean
hasVar(string $name)

Checks if variable exists.

array
getVar(string $name, string $default = null)

Returns a query variable by name.

string
getQuery(boolean $toArray = false)

Returns flat query string.

string
getScheme()

Get URI scheme (protocol) ie. http, https, ftp, etc.

string
getUser()

Get URI username Returns the username, or null if no username was specified.

string
getPass()

Get URI password Returns the password, or null if no password was specified.

string
getUserInfo()

Retrieve the user information component of the URI.

string
getHost()

Get URI host Returns the hostname/ip or null if no hostname/ip was specified.

integer
getPort()

Get URI port Returns the port number, or null if no port was specified.

string
getPath()

Gets the URI path string.

string
getFragment()

Get the URI archor string Everything after the "#".

boolean
isSSL()

Checks whether the current URI is using HTTPS.

string
getOriginal()

getUri

string
setVar(string $name, string $value)

Adds a query variable and value, replacing the value if it already exists and returning the old value.

void
delVar(string $name)

Removes an item from the query string variables if it exists.

void
setQuery(mixed $query)

Sets the query to a supplied string in format: foo=bar&x=y

void
setScheme(string $scheme)

Set URI scheme (protocol) ie. http, https, ftp, etc.

void
setUser(string $user)

Set URI username.

void
setPass(string $pass)

Set URI password.

void
setHost(string $host)

Set URI host.

void
setPort(integer $port)

Set URI port.

void
setPath(string $path)

Set the URI path string.

void
setFragment(string $anchor)

Set the URI anchor string everything after the "#".

Details

in AbstractUri at line line 93
__construct(string $uri = null)

Constructor.

You can pass a URI string to the constructor to initialise a specific URI.

Parameters

string $uri The optional URI string

string __toString()

Magic method to get the string representation of the URI object.

Return Value

string

string toString(array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment'))

Returns full uri string.

Parameters

array $parts An array specifying the parts to render.

Return Value

string The rendered URI string.

boolean hasVar(string $name)

Checks if variable exists.

Parameters

string $name Name of the query variable to check.

Return Value

boolean True if the variable exists.

array getVar(string $name, string $default = null)

Returns a query variable by name.

Parameters

string $name Name of the query variable to get.
string $default Default value to return if the variable is not set.

Return Value

array Query variables.

string getQuery(boolean $toArray = false)

Returns flat query string.

Parameters

boolean $toArray True to return the query as a key => value pair array.

Return Value

string Query string.

string getScheme()

Get URI scheme (protocol) ie. http, https, ftp, etc.

..

Return Value

string The URI scheme.

string getUser()

Get URI username Returns the username, or null if no username was specified.

Return Value

string The URI username.

string getPass()

Get URI password Returns the password, or null if no password was specified.

Return Value

string The URI password.

string getUserInfo()

Retrieve the user information component of the URI.

If no user information is present, this method MUST return an empty string.

If a user is present in the URI, this will return that value; additionally, if the password is also present, it will be appended to the user value, with a colon (":") separating the values.

The trailing "@" character is not part of the user information and MUST NOT be added.

Return Value

string The URI user information, in "username[:password]" format.

string getHost()

Get URI host Returns the hostname/ip or null if no hostname/ip was specified.

Return Value

string The URI host.

integer getPort()

Get URI port Returns the port number, or null if no port was specified.

Return Value

integer The URI port number.

string getPath()

Gets the URI path string.

Return Value

string The URI path string.

string getFragment()

Get the URI archor string Everything after the "#".

Return Value

string The URI anchor string.

boolean isSSL()

Checks whether the current URI is using HTTPS.

Return Value

boolean True if using SSL via HTTPS.

string getOriginal()

getUri

Return Value

string

at line line 34
string setVar(string $name, string $value)

Adds a query variable and value, replacing the value if it already exists and returning the old value.

Parameters

string $name Name of the query variable to set.
string $value Value of the query variable.

Return Value

string Previous value for the query variable.

at line line 55
void delVar(string $name)

Removes an item from the query string variables if it exists.

Parameters

string $name Name of variable to remove.

Return Value

void

at line line 76
void setQuery(mixed $query)

Sets the query to a supplied string in format: foo=bar&x=y

Parameters

mixed $query The query string or array.

Return Value

void

at line line 106
void setScheme(string $scheme)

Set URI scheme (protocol) ie. http, https, ftp, etc.

..

Parameters

string $scheme The URI scheme.

Return Value

void

at line line 120
void setUser(string $user)

Set URI username.

Parameters

string $user The URI username.

Return Value

void

at line line 134
void setPass(string $pass)

Set URI password.

Parameters

string $pass The URI password.

Return Value

void

at line line 148
void setHost(string $host)

Set URI host.

Parameters

string $host The URI host.

Return Value

void

at line line 162
void setPort(integer $port)

Set URI port.

Parameters

integer $port The URI port number.

Return Value

void

at line line 176
void setPath(string $path)

Set the URI path string.

Parameters

string $path The URI path string.

Return Value

void

at line line 191
void setFragment(string $anchor)

Set the URI anchor string everything after the "#".

Parameters

string $anchor The URI anchor string.

Return Value

void