3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
13 * Interface defining a URI
15 interface UriInterface
18 * Create a new URI object
20 * @param Uri|string|null $uri
21 * @throws Exception\InvalidArgumentException
23 public function __construct($uri = null);
26 * Check if the URI is valid
28 * Note that a relative URI may still be valid
32 public function isValid();
35 * Check if the URI is a valid relative URI
39 public function isValidRelative();
42 * Check if the URI is an absolute or relative URI
46 public function isAbsolute();
54 public function parse($uri);
57 * Compose the URI into a string
60 * @throws Exception\InvalidUriException
62 public function toString();
67 * Normalizing a URI includes removing any redundant parent directory or
68 * current directory references from the path (e.g. foo/bar/../baz becomes
69 * foo/baz), normalizing the scheme case, decoding any over-encoded
72 * Eventually, two normalized URLs pointing to the same resource should be
73 * equal even if they were originally represented by two different strings
77 public function normalize();
80 * Convert the link to a relative link by substracting a base URI
82 * This is the opposite of resolving a relative link - i.e. creating a
83 * relative reference link from an original URI and a base URI.
85 * If the two URIs do not intersect (e.g. the original URI is not in any
86 * way related to the base URI) the URI will not be modified.
88 * @param Uri|string $baseUri
91 public function makeRelative($baseUri);
94 * Get the scheme part of the URI
98 public function getScheme();
101 * Get the User-info (usually user:password) part
103 * @return string|null
105 public function getUserInfo();
110 * @return string|null
112 public function getHost();
119 public function getPort();
124 * @return string|null
126 public function getPath();
131 * @return string|null
133 public function getQuery();
136 * Return the query string as an associative array of key => value pairs
138 * This is an extension to RFC-3986 but is quite useful when working with
139 * most common URI types
143 public function getQueryAsArray();
146 * Get the URI fragment
148 * @return string|null
150 public function getFragment();
155 * If the scheme is not valid according to the generic scheme syntax or
156 * is not acceptable by the specific URI class (e.g. 'http' or 'https' are
157 * the only acceptable schemes for the Zend\Uri\Http class) an exception
160 * You can check if a scheme is valid before setting it using the
161 * validateScheme() method.
163 * @param string $scheme
164 * @throws Exception\InvalidUriPartException
167 public function setScheme($scheme);
170 * Set the URI User-info part (usually user:password)
172 * @param string $userInfo
174 * @throws Exception\InvalidUriPartException If the schema definition
175 * does not have this part
177 public function setUserInfo($userInfo);
182 * Note that the generic syntax for URIs allows using host names which
183 * are not necessarily IPv4 addresses or valid DNS host names. For example,
184 * IPv6 addresses are allowed as well, and also an abstract "registered name"
185 * which may be any name composed of a valid set of characters, including,
186 * for example, tilda (~) and underscore (_) which are not allowed in DNS
189 * Subclasses of Uri may impose more strict validation of host names - for
190 * example the HTTP RFC clearly states that only IPv4 and valid DNS names
191 * are allowed in HTTP URIs.
193 * @param string $host
194 * @throws Exception\InvalidUriPartException
197 public function setHost($host);
200 * Set the port part of the URI
205 public function setPort($port);
210 * @param string $path
213 public function setPath($path);
216 * Set the query string
218 * If an array is provided, will encode this array of parameters into a
219 * query string. Array values will be represented in the query string using
220 * PHP's common square bracket notation.
222 * @param string|array $query
225 public function setQuery($query);
228 * Set the URI fragment part
230 * @param string $fragment
232 * @throws Exception\InvalidUriPartException If the schema definition
233 * does not have this part
235 public function setFragment($fragment);
238 * Magic method to convert the URI to a string
242 public function __toString();