class AbstractUri implements UriInterface (View source)

Uri Class

Abstract base for out uri classes.

This class should be considered an implementation detail. Typehint against UriInterface.

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

Details

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

at line line 108
string __toString()

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

Return Value

string

at line line 122
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.

at line line 149
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.

at line line 164
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.

at line line 183
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.

at line line 207
string getScheme()

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

..

Return Value

string The URI scheme.

at line line 220
string getUser()

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

Return Value

string The URI username.

at line line 233
string getPass()

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

Return Value

string The URI password.

at line line 255
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.

at line line 275
string getHost()

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

Return Value

string The URI host.

at line line 288
integer getPort()

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

Return Value

integer The URI port number.

at line line 300
string getPath()

Gets the URI path string.

Return Value

string The URI path string.

at line line 313
string getFragment()

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

Return Value

string The URI anchor string.

at line line 325
boolean isSSL()

Checks whether the current URI is using HTTPS.

Return Value

boolean True if using SSL via HTTPS.

at line line 384
string getOriginal()

getUri

Return Value

string