ExtendedUriTrait
trait ExtendedUriTrait (View source)
Provides convenience methods for accessing the standard URI interface.
ExtendedUriTrait provides additional methods for common use cases that build on top the standard URI interface. Note that due to RFC 3986 compliance, the methods do not treat the plus sign as a space character.
Methods
Returns the scheme component of the URI.
Returns the standard port for the current scheme.
Returns the user information component of the URI.
Returns the decoded username from the URI.
Returns the decoded password from the URI.
Returns the host component of the URI.
Returns the IP address from the host component.
Returns the top level domain from the host component.
Returns the path component of the URI.
Returns the decoded path segments from the path component.
Returns the file extension for the last segment in the path.
Returns the query string of the URI.
Returns the decoded parameters parsed from the query component.
Returns a URI instance with the specified path.
Returns a URI instance with path constructed from given path segments.
Returns a URI instance with the specified query string.
Returns a URI instance with the query constructed from the given parameters.
Details
at line 29
abstract string
getScheme()
Returns the scheme component of the URI.
at line 42
int|null
getStandardPort()
Returns the standard port for the current scheme.
The known ports are:
- ftp : 21
- http : 80
- https : 443
at line 57
abstract string
getUserInfo()
Returns the user information component of the URI.
at line 63
string
getUsername()
Returns the decoded username from the URI.
at line 75
string
getPassword()
Returns the decoded password from the URI.
at line 86
abstract string
getHost()
Returns the host component of the URI.
at line 92
string|null
getIpAddress()
Returns the IP address from the host component.
at line 117
string
getTopLevelDomain()
Returns the top level domain from the host component.
Note that if the host component represents an IP address, an empty string will be returned instead. Additionally, if the host component ends in a period, the section prior that period will be returned instead. If no period is present in the host component, the entire host component will be returned.
at line 138
abstract string
getPath()
Returns the path component of the URI.
at line 144
string[]
getPathSegments()
Returns the decoded path segments from the path component.
at line 156
string
getPathExtension()
Returns the file extension for the last segment in the path.
at line 173
abstract string
getQuery()
Returns the query string of the URI.
at line 179
array
getQueryParameters()
Returns the decoded parameters parsed from the query component.
at line 191
abstract ExtendedUriTrait
withPath(string $path)
Returns a URI instance with the specified path.
at line 204
ExtendedUriTrait
withPathSegments(array $segments)
Returns a URI instance with path constructed from given path segments.
Note that all the segments are assumed to be decoded. Thus any percent encoded characters in the segments will be double encoded. Due to aggressive encoding, this method will encode even the forward slashes in the provided segments.
at line 216
abstract ExtendedUriTrait
withQuery(string $query)
Returns a URI instance with the specified query string.
at line 230
ExtendedUriTrait
withQueryParameters(array $parameters)
Returns a URI instance with the query constructed from the given parameters.
The provided associative array will be used to construct the query string. Even characters such as the ampersand and equal sign will be encoded in resulting string. Note the any percent encoded characters will be double encoded, since this method assumes that all the values are unencoded.