PsrUri
class PsrUri extends AbstractUri implements UriInterface (View source)
The PsrUri class.
Constants
SCHEME_HTTP |
|
SCHEME_HTTPS |
|
CHAR_SUB_DELIMS |
Sub-delimiters used in query strings and fragments. |
CHAR_UNRESERVED |
Unreserved characters used in paths, query strings, and fragments. |
Methods
Constructor.
Magic method to get the string representation of the URI object.
Returns full uri string.
Returns a query variable by name.
Get URI username Returns the username, or null if no username was specified.
Get URI password Returns the password, or null if no password was specified.
Get URI host Returns the hostname/ip or null if no hostname/ip was specified.
Get URI port Returns the port number, or null if no port was specified.
Retrieve the authority component of the URI.
Return an instance with the specified scheme.
Return an instance with the specified user information.
Return an instance with the specified URI fragment.
Details
at line line 52
__construct(string $uri = '')
Constructor.
You can pass a URI string to the constructor to initialise a specific URI.
in AbstractUri at line line 108
string
__toString()
Magic method to get the string representation of the URI object.
in AbstractUri at line line 122
string
toString(array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment'))
Returns full uri string.
in AbstractUri at line line 149
boolean
hasVar(string $name)
Checks if variable exists.
in AbstractUri at line line 164
array
getVar(string $name, string $default = null)
Returns a query variable by name.
in AbstractUri at line line 183
string
getQuery(boolean $toArray = false)
Returns flat query string.
in AbstractUri at line line 207
string
getScheme()
Get URI scheme (protocol) ie. http, https, ftp, etc.
..
in AbstractUri at line line 220
string
getUser()
Get URI username Returns the username, or null if no username was specified.
in AbstractUri at line line 233
string
getPass()
Get URI password Returns the password, or null if no password was specified.
in AbstractUri 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.
in AbstractUri at line line 275
string
getHost()
Get URI host Returns the hostname/ip or null if no hostname/ip was specified.
in AbstractUri at line line 288
integer
getPort()
Get URI port Returns the port number, or null if no port was specified.
in AbstractUri at line line 300
string
getPath()
Gets the URI path string.
in AbstractUri at line line 313
string
getFragment()
Get the URI archor string Everything after the "#".
in AbstractUri at line line 325
boolean
isSSL()
Checks whether the current URI is using HTTPS.
in AbstractUri at line line 384
string
getOriginal()
getUri
at line line 81
string
getAuthority()
Retrieve the authority component of the URI.
If no authority information is present, this method MUST return an empty string.
The authority syntax of the URI is:
[user-info@]host[:port]
If the port component is not set or is the standard port for the current scheme, it SHOULD NOT be included.
at line line 122
PsrUri
withScheme(string $scheme)
Return an instance with the specified scheme.
This method MUST retain the state of the current instance, and return an instance that contains the specified scheme.
Implementations MUST support the schemes "http" and "https" case insensitively, and MAY accommodate other schemes if required.
An empty scheme is equivalent to removing the scheme.
at line line 152
PsrUri
withUserInfo(string $user, string $password = null)
Return an instance with the specified user information.
This method MUST retain the state of the current instance, and return an instance that contains the specified user information.
Password is optional, but the user information MUST include the user; an empty string for the user is equivalent to removing user information.
at line line 185
PsrUri
withHost(string $host)
Return an instance with the specified host.
This method MUST retain the state of the current instance, and return an instance that contains the specified host.
An empty host value is equivalent to removing the host.
at line line 216
PsrUri
withPort(int $port)
Return an instance with the specified port.
This method MUST retain the state of the current instance, and return an instance that contains the specified port.
Implementations MUST raise an exception for ports outside the established TCP and UDP port ranges.
A null value provided for the port is equivalent to removing the port information.
at line line 262
PsrUri
withPath(string $path)
Return an instance with the specified path.
This method MUST retain the state of the current instance, and return an instance that contains the specified path.
The path can either be empty or absolute (starting with a slash) or rootless (not starting with a slash). Implementations MUST support all three syntaxes.
If the path is intended to be domain-relative rather than path relative then it must begin with a slash ("/"). Paths not starting with a slash ("/") are assumed to be relative to some base path known to the application or consumer.
Users can provide both encoded and decoded path characters. Implementations ensure the correct encoding as outlined in getPath().
at line line 301
PsrUri
withQuery(string|array $query)
Return an instance with the specified query string.
This method MUST retain the state of the current instance, and return an instance that contains the specified query string.
Users can provide both encoded and decoded query characters. Implementations ensure the correct encoding as outlined in getQuery().
An empty query string value is equivalent to removing the query string.
at line line 332
PsrUri
withFragment(string $fragment)
Return an instance with the specified URI fragment.
This method MUST retain the state of the current instance, and return an instance that contains the specified URI fragment.
Users can provide both encoded and decoded fragment characters. Implementations ensure the correct encoding as outlined in getFragment().
An empty fragment value is equivalent to removing the fragment.