3 * @see https://github.com/zendframework/zend-uri for the canonical source repository
4 * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
5 * @license https://github.com/zendframework/zend-uri/blob/master/LICENSE.md New BSD License
11 * Interface defining a URI
13 interface UriInterface
16 * Create a new URI object
18 * @param Uri|string|null $uri
19 * @throws Exception\InvalidArgumentException
21 public function __construct($uri = null);
24 * Check if the URI is valid
26 * Note that a relative URI may still be valid
30 public function isValid();
33 * Check if the URI is a valid relative URI
37 public function isValidRelative();
40 * Check if the URI is an absolute or relative URI
44 public function isAbsolute();
52 public function parse($uri);
55 * Compose the URI into a string
58 * @throws Exception\InvalidUriException
60 public function toString();
65 * Normalizing a URI includes removing any redundant parent directory or
66 * current directory references from the path (e.g. foo/bar/../baz becomes
67 * foo/baz), normalizing the scheme case, decoding any over-encoded
70 * Eventually, two normalized URLs pointing to the same resource should be
71 * equal even if they were originally represented by two different strings
75 public function normalize();
78 * Convert the link to a relative link by substracting a base URI
80 * This is the opposite of resolving a relative link - i.e. creating a
81 * relative reference link from an original URI and a base URI.
83 * If the two URIs do not intersect (e.g. the original URI is not in any
84 * way related to the base URI) the URI will not be modified.
86 * @param Uri|string $baseUri
89 public function makeRelative($baseUri);
92 * Get the scheme part of the URI
96 public function getScheme();
99 * Get the User-info (usually user:password) part
101 * @return string|null
103 public function getUserInfo();
108 * @return string|null
110 public function getHost();
117 public function getPort();
122 * @return string|null
124 public function getPath();
129 * @return string|null
131 public function getQuery();
134 * Return the query string as an associative array of key => value pairs
136 * This is an extension to RFC-3986 but is quite useful when working with
137 * most common URI types
141 public function getQueryAsArray();
144 * Get the URI fragment
146 * @return string|null
148 public function getFragment();
153 * If the scheme is not valid according to the generic scheme syntax or
154 * is not acceptable by the specific URI class (e.g. 'http' or 'https' are
155 * the only acceptable schemes for the Zend\Uri\Http class) an exception
158 * You can check if a scheme is valid before setting it using the
159 * validateScheme() method.
161 * @param string $scheme
162 * @throws Exception\InvalidUriPartException
165 public function setScheme($scheme);
168 * Set the URI User-info part (usually user:password)
170 * @param string $userInfo
172 * @throws Exception\InvalidUriPartException If the schema definition
173 * does not have this part
175 public function setUserInfo($userInfo);
180 * Note that the generic syntax for URIs allows using host names which
181 * are not necessarily IPv4 addresses or valid DNS host names. For example,
182 * IPv6 addresses are allowed as well, and also an abstract "registered name"
183 * which may be any name composed of a valid set of characters, including,
184 * for example, tilda (~) and underscore (_) which are not allowed in DNS
187 * Subclasses of Uri may impose more strict validation of host names - for
188 * example the HTTP RFC clearly states that only IPv4 and valid DNS names
189 * are allowed in HTTP URIs.
191 * @param string $host
192 * @throws Exception\InvalidUriPartException
195 public function setHost($host);
198 * Set the port part of the URI
203 public function setPort($port);
208 * @param string $path
211 public function setPath($path);
214 * Set the query string
216 * If an array is provided, will encode this array of parameters into a
217 * query string. Array values will be represented in the query string using
218 * PHP's common square bracket notation.
220 * @param string|array $query
223 public function setQuery($query);
226 * Set the URI fragment part
228 * @param string $fragment
230 * @throws Exception\InvalidUriPartException If the schema definition
231 * does not have this part
233 public function setFragment($fragment);
236 * Magic method to convert the URI to a string
240 public function __toString();