Uri Class
Abstract base for out uri classes.
This class should be considered an implementation detail. Typehint against
UriInterface.
public
|
#
__construct( string $uri = null )
Constructor. You can pass a URI string to the constructor to initialise a
specific URI.
Constructor. You can pass a URI string to the constructor to initialise a
specific URI.
Parameters
- $uri
string - $uri The optional URI string
Since
1.0
|
public
string
|
#
__toString( )
Magic method to get the string representation of the URI object.
Magic method to get the string representation of the URI object.
Returns
string
Since
1.0
Implementation of
|
public
string
|
#
toString( array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment') )
Returns full uri string.
Parameters
- $parts
array - $parts An array specifying the parts to render.
Returns
string - The rendered URI string.
Since
1.0
Implementation of
|
public
boolean
|
#
hasVar( string $name )
Checks if variable exists.
Checks if variable exists.
Parameters
- $name
string - $name Name of the query variable to check.
Returns
boolean - True if the variable exists.
Since
1.0
Implementation of
|
public
array
|
#
getVar( string $name, string $default = null )
Returns a query variable by name.
Returns a query variable by name.
Parameters
- $name
string - $name Name of the query variable to get.
- $default
string - $default Default value to return if the variable is not set.
Returns
array - Query variables.
Since
1.0
Implementation of
|
public
string
|
#
getQuery( boolean $toArray = false )
Returns flat query string.
Returns flat query string.
Parameters
- $toArray
boolean - $toArray True to return the query as a key => value pair array.
Returns
string - Query string.
Since
1.0
Implementation of
|
public
string
|
#
getScheme( )
Get URI scheme (protocol) ie. http, https, ftp, etc...
Get URI scheme (protocol) ie. http, https, ftp, etc...
Returns
string - The URI scheme.
Since
1.0
Implementation of
|
public
string
|
#
getUser( )
Get URI username Returns the username, or null if no username was
specified.
Get URI username Returns the username, or null if no username was
specified.
Returns
string - The URI username.
Since
1.0
Implementation of
|
public
string
|
#
getPass( )
Get URI password Returns the password, or null if no password was
specified.
Get URI password Returns the password, or null if no password was
specified.
Returns
string - The URI password.
Since
1.0
Implementation of
|
public
string
|
#
getHost( )
Get URI host Returns the hostname/ip or null if no hostname/ip was
specified.
Get URI host Returns the hostname/ip or null if no hostname/ip was
specified.
Returns
string - The URI host.
Since
1.0
Implementation of
|
public
integer
|
#
getPort( )
Get URI port Returns the port number, or null if no port was specified.
Get URI port Returns the port number, or null if no port was specified.
Returns
integer - The URI port number.
Since
1.0
Implementation of
|
public
string
|
#
getPath( )
Gets the URI path string.
Gets the URI path string.
Returns
string - The URI path string.
Since
1.0
Implementation of
|
public
string
|
#
getFragment( )
Get the URI archor string Everything after the "#".
Get the URI archor string Everything after the "#".
Returns
string - The URI anchor string.
Since
1.0
Implementation of
|
public
boolean
|
#
isSSL( )
Checks whether the current URI is using HTTPS.
Checks whether the current URI is using HTTPS.
Returns
boolean - True if using SSL via HTTPS.
Since
1.0
Implementation of
|
protected static
string
|
#
buildQuery( array $params )
Build a query from an array (reverse of the PHP parse_str()).
Build a query from an array (reverse of the PHP parse_str()).
Parameters
- $params
array - $params The array of key => value pairs to return as a query string.
Returns
string - The resulting query string.
Since
1.0
See
parse_str()
|
protected
boolean
|
#
parse( string $uri )
Parse a given URI and populate the class fields.
Parse a given URI and populate the class fields.
Parameters
- $uri
string - $uri The URI string to parse.
Returns
boolean - True on success.
Since
1.0
|
protected
string
|
#
cleanPath( string $path )
Resolves //, ../ and ./ from a path and returns the result. Eg:
Resolves //, ../ and ./ from a path and returns the result. Eg:
/foo/bar/../boo.php => /foo/boo.php /foo/bar/../../boo.php => /boo.php
/foo/bar/.././/boo.php => /foo/boo.php
Parameters
- $path
string - $path The URI path to clean.
Returns
string - Cleaned and resolved URI path.
Since
1.0
|