|
Erebot
latest
A modular IRC bot for PHP 5.3+
|
Simple parser/generator for Uniform Resource Identifiers as defined in RFC 3986. More...
Inheritance diagram for Erebot\URI:Public Member Functions | |
| __construct ($uri=array()) | |
| __toString () | |
| asParsedURL ($component=-1) | |
| getFragment ($raw=false) | |
| getHost ($raw=false) | |
| getPath ($raw=false) | |
| getPort ($raw=false) | |
| getQuery ($raw=false) | |
| getScheme ($raw=false) | |
| getUserInfo ($raw=false) | |
| relative ($reference) | |
| setFragment ($fragment) | |
| setHost ($host) | |
| setPath ($path) | |
| setPort ($port) | |
| setQuery ($query) | |
| setScheme ($scheme) | |
| setUserInfo ($userinfo) | |
| toURI ($raw=false, $credentials=true) | |
Static Public Member Functions | |
| static | fromAbsPath ($abspath, $strict=true) |
| static | normalizePercentReal ($hexchr) |
Protected Member Functions | |
| merge ($path) | |
| parseURI ($uri, $relative) | |
| realSetPath ($path, $relative) | |
| removeDotSegments ($path) | |
| validatePath ($path, $relative) | |
Static Protected Member Functions | |
| static | normalizePercent ($data) |
Protected Attributes | |
| $fragment | |
| Fragment component. | |
| $host | |
| Host component ("authority", even though "authority" is more general). | |
| $path | |
| Path component. | |
| $port | |
| Port component. | |
| $query | |
| Query component. | |
| $scheme | |
| Scheme component (sometimes also erroneously called a "protocol"). | |
| $userinfo | |
| User information component (such as a "username:password" pair). | |
Simple parser/generator for Uniform Resource Identifiers as defined in RFC 3986.
This class can be used as both a parser and a generator for Uniform Resource Identifiers (URI) as defined in RFC 3986. It is primarly meant to deal with with absolute URIs but also offers methods to deal with relative URIs. It is mostly compatible with parse_url(), but tends to be stricter when validating data.
This implementation doesn't assume that the "userinfo" part is made up of a "username:password" pair (in contrast to parse_url() which is initially based on RFC 1738), and provides a single field named "userinfo" instead. Such pairs will be merged upon encounter.
This implementation is also compatible with RFC 6874 which adds support for IPv6 zone identifiers.
All components are normalized by default when retrieved using any of the getters except asParsedURL(). You may override this behaviour by passing $raw=true to said getters. Normalization is done using the rules defined in RFC 3986.
| Erebot\URI::__construct | ( | $uri = array() | ) |
Constructs an URI.
| mixed | $uri | (optional) Either a string representing the URI or an array as returned by PHP's parse_url() function. Defaults to an empty URI (which must be populated afterwards using the setters from this API) if omitted. |
| ::InvalidArgumentException | The given URI is invalid. |
| Erebot\URI::__toString | ( | ) |
Returns the current URI as a string, in its normalized form.
Implements Erebot\URIInterface.
| Erebot\URI::asParsedURL | ( | $component = -1 | ) |
Returns information about the current URI, in the same format as parse_url().
| $component | (optional) A specific component to return. Read the documentation about parse_url() for more information. |
| mixed | Either an array, a string, an integer or null, depending on $component and the actual contents of this URI. Read the documentation about parse_url() for more information. |
Implements Erebot\URIInterface.
|
static |
Given an absolute path to some file or directory, returns an URL belonging to the "file" schema and pointing to that file/directory.
| string | $abspath | Absolute path to the file or directory to refer to. |
| bool | $strict | (optional) Whether strict parsing rules apply or not. Defaults to true. When set to false, '/' is treated as a path separator even on systems where it is not the native separator (eg. Windows). |
| Erebot::URI | An URL poiting to the same file/directory and belonging to the "file" scheme. |
| ::InvalidArgumentException | The given $abspath was invalid. |
Implements Erebot\URIInterface.
Definition at line 857 of file URI.php.
Referenced by Erebot\Config\Main\load().
| Erebot\URI::getFragment | ( | $raw = false | ) |
Returns the current URI's fragment.
| bool | $raw | (optional) Whether the value should be normalized prior to being returned (false) or not (true). The default is to apply normalization. |
| mixed | The current URI's fragment as a string, eventually normalized or null. |
Implements Erebot\URIInterface.
| Erebot\URI::getHost | ( | $raw = false | ) |
Returns the current URI's host.
| bool | $raw | (optional) Whether the value should be normalized prior to being returned (false) or not (true). The default is to apply normalization. |
| mixed | The current URI's host as a string, eventually normalized or null. |
Implements Erebot\URIInterface.
| Erebot\URI::getPath | ( | $raw = false | ) |
Returns the current URI's path.
| bool | $raw | (optional) Whether the value should be normalized prior to being returned (false) or not (true). The default is to apply normalization. |
| string | The current URI's path as a string, eventually normalized. |
Implements Erebot\URIInterface.
| Erebot\URI::getPort | ( | $raw = false | ) |
Returns the current URI's port.
| bool | $raw | (optional) Whether the value should be normalized prior to being returned (false) or not (true). The default is to apply normalization. |
| mixed | When normalization is in effect, the port for the current URI will be returned as an integer, or null. When normalization has been disabled, the port will be returned as a string or null. |
Implements Erebot\URIInterface.
| Erebot\URI::getQuery | ( | $raw = false | ) |
Returns the current URI's query.
| bool | $raw | (optional) Whether the value should be normalized prior to being returned (false) or not (true). The default is to apply normalization. |
| mixed | The current URI's query as a string, eventually normalized or null. |
Implements Erebot\URIInterface.
| Erebot\URI::getScheme | ( | $raw = false | ) |
Returns the current URI's scheme.
| bool | $raw | (optional) Whether the value should be normalized prior to being returned (false) or not (true). The default is to apply normalization. |
| string | The current URI's scheme as a string, eventually normalized. |
Implements Erebot\URIInterface.
| Erebot\URI::getUserInfo | ( | $raw = false | ) |
Returns the current URI's user information.
| bool | $raw | (optional) Whether the value should be normalized prior to being returned (false) or not (true). The default is to apply normalization. |
| mixed | The current URI's user information, eventually normalized or null. |
Implements Erebot\URIInterface.
|
protected |
|
staticprotected |
Performs normalization of percent-encoded characters.
| string | $data | Some text containing percent-encoded characters that need to be normalized. |
| string | The same text, after percent-encoding normalization. |
|
static |
|
protected |
Parses an URI using the grammar defined in RFC 3986.
| string | $uri | URI to parse. |
| bool | $relative | Whether $uri must be considered as an absolute URI (false) or a relative reference (true). |
| array | An associative array containing the different components that could be parsed out of this URI. It uses the same format as parse_url(), except that the "user" and "pass" components are merged into a single "userinfo" component and only string keys are defined. |
| ::InvalidArgumentException | The given $uri is not valid. |
|
protected |
| Erebot\URI::relative | ( | $reference | ) |
Given a relative reference, returns a new absolute URI matching that reference.
| string | $reference | Some relative reference (can be an absolute or relative URI). The current absolute URI is used as the base to dereference it. |
| Erebot::URI | A new absolute URI matching the given $reference. |
| ::InvalidArgumentException | The given $reference is not valid. |
Implements Erebot\URIInterface.
|
protected |
| Erebot\URI::setFragment | ( | $fragment | ) |
Sets the current URI's fragment.
| mixed | $fragment | New fragment for this URI (either a string or null). |
| ::InvalidArgumentException | The given $fragment is not valid. |
Implements Erebot\URIInterface.
| Erebot\URI::setHost | ( | $host | ) |
Sets the current URI's host.
| string | $host | New host for this URI (either a string or null). |
| ::InvalidArgumentException | The given $host is not valid. |
Implements Erebot\URIInterface.
| Erebot\URI::setPath | ( | $path | ) |
Sets the current URI's path.
| string | $path | New path for this URI. |
| ::InvalidArgumentException | The given $path is not valid. |
Implements Erebot\URIInterface.
| Erebot\URI::setPort | ( | $port | ) |
Sets the current URI's port.
| mixed | $port | New port for this URI (either a numeric string, an integer or null). |
| ::InvalidArgumentException | The given $port is not valid. |
Implements Erebot\URIInterface.
| Erebot\URI::setQuery | ( | $query | ) |
Sets the current URI's query.
| mixed | $query | New query for this URI (either a string or null). |
| ::InvalidArgumentException | The given $query is not valid. |
Implements Erebot\URIInterface.
| Erebot\URI::setScheme | ( | $scheme | ) |
Sets the current URI's scheme.
| string | $scheme | New scheme for this URI, as a string. |
| ::InvalidArgumentException | The given $scheme is not valid. |
Implements Erebot\URIInterface.
| Erebot\URI::setUserInfo | ( | $userinfo | ) |
Sets the current URI's user information.
| mixed | $userinfo | New user information for this URI (either a string or null). |
| ::InvalidArgumentException | The given user information is not valid. |
Implements Erebot\URIInterface.
| Erebot\URI::toURI | ( | $raw = false, |
|
$credentials = true |
|||
| ) |
Returns the current URI as a string.
| bool | $raw | (optional) Whether the raw contents of the components should be used (true) or a normalized alternative (false). The default is to apply normalization. |
| bool | $credentials | (optional) Whether the content of the "user information" component should be part of the returned string (true) or not (false). The default is for such credentials to appear in the result. |
| string | The current URI as a string, eventually normalized. |
Implements Erebot\URIInterface.
|
protected |