UriContract.php
179 lines
| 1 | <?php |
| 2 | namespace Ollyo\PaymentHub\Contracts\Support; |
| 3 | |
| 4 | interface UriContract |
| 5 | { |
| 6 | /** |
| 7 | * Include the scheme (http, https, etc.) |
| 8 | * |
| 9 | * @var integer |
| 10 | * @since 1.2.0 |
| 11 | */ |
| 12 | public const SCHEME = 1; |
| 13 | |
| 14 | /** |
| 15 | * Include the host |
| 16 | * |
| 17 | * @var integer |
| 18 | * @since 1.2.0 |
| 19 | */ |
| 20 | public const HOST = 8; |
| 21 | |
| 22 | /** |
| 23 | * Include the port |
| 24 | * |
| 25 | * @var integer |
| 26 | * @since 1.2.0 |
| 27 | */ |
| 28 | public const PORT = 16; |
| 29 | |
| 30 | /** |
| 31 | * Include the path |
| 32 | * |
| 33 | * @var integer |
| 34 | * @since 1.2.0 |
| 35 | */ |
| 36 | public const PATH = 32; |
| 37 | |
| 38 | /** |
| 39 | * Include the query string |
| 40 | * |
| 41 | * @var integer |
| 42 | * @since 1.2.0 |
| 43 | */ |
| 44 | public const QUERY = 64; |
| 45 | |
| 46 | /** |
| 47 | * Include the fragment |
| 48 | * |
| 49 | * @var integer |
| 50 | * @since 1.2.0 |
| 51 | */ |
| 52 | public const FRAGMENT = 128; |
| 53 | |
| 54 | /** |
| 55 | * Include all available url parts (scheme, user, pass, host, port, path, query, fragment) |
| 56 | * |
| 57 | * @var integer |
| 58 | * @since 1.2.0 |
| 59 | */ |
| 60 | public const ALL = 255; |
| 61 | |
| 62 | /** |
| 63 | * Magic method to get the string representation of the URI object. |
| 64 | * |
| 65 | * @return string |
| 66 | * |
| 67 | * @since 1.0 |
| 68 | */ |
| 69 | public function __toString(); |
| 70 | |
| 71 | /** |
| 72 | * Returns full URI string. |
| 73 | * |
| 74 | * @param array $parts An array of strings specifying the parts to render. |
| 75 | * |
| 76 | * @return string The rendered URI string. |
| 77 | * |
| 78 | * @since 1.0 |
| 79 | */ |
| 80 | public function toString($parts = ['scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment']); |
| 81 | |
| 82 | /** |
| 83 | * Checks if variable exists. |
| 84 | * |
| 85 | * @param string $name Name of the query variable to check. |
| 86 | * |
| 87 | * @return boolean True if the variable exists. |
| 88 | * |
| 89 | * @since 1.0 |
| 90 | */ |
| 91 | public function hasVar($name); |
| 92 | |
| 93 | /** |
| 94 | * Returns a query variable by name. |
| 95 | * |
| 96 | * @param string $name Name of the query variable to get. |
| 97 | * @param string $default Default value to return if the variable is not set. |
| 98 | * |
| 99 | * @return mixed Requested query variable if present otherwise the default value. |
| 100 | * |
| 101 | * @since 1.0 |
| 102 | */ |
| 103 | public function getVar($name, $default = null); |
| 104 | |
| 105 | |
| 106 | /** |
| 107 | * Set a query param variable |
| 108 | * |
| 109 | * @param string $name |
| 110 | * @param string $value |
| 111 | * @return void |
| 112 | */ |
| 113 | public function setVar($name, $value); |
| 114 | |
| 115 | /** |
| 116 | * Returns flat query string. |
| 117 | * |
| 118 | * @param boolean $toArray True to return the query as a key => value pair array. |
| 119 | * |
| 120 | * @return array|string Query string, optionally as an array. |
| 121 | * |
| 122 | * @since 1.0 |
| 123 | */ |
| 124 | public function getQuery($toArray = false); |
| 125 | |
| 126 | /** |
| 127 | * Get the URI scheme (protocol) |
| 128 | * |
| 129 | * @return string The URI scheme. |
| 130 | * |
| 131 | * @since 1.0 |
| 132 | */ |
| 133 | public function getScheme(); |
| 134 | |
| 135 | /** |
| 136 | * Get the URI host |
| 137 | * |
| 138 | * @return string The hostname/IP or null if no hostname/IP was specified. |
| 139 | * |
| 140 | * @since 1.0 |
| 141 | */ |
| 142 | public function getHost(); |
| 143 | |
| 144 | /** |
| 145 | * Get the URI port |
| 146 | * |
| 147 | * @return integer The port number, or null if no port was specified. |
| 148 | * |
| 149 | * @since 1.0 |
| 150 | */ |
| 151 | public function getPort(); |
| 152 | |
| 153 | /** |
| 154 | * Gets the URI path string |
| 155 | * |
| 156 | * @return string The URI path string. |
| 157 | * |
| 158 | * @since 1.0 |
| 159 | */ |
| 160 | public function getPath(); |
| 161 | |
| 162 | /** |
| 163 | * Get the URI archor string |
| 164 | * |
| 165 | * @return string The URI anchor string. |
| 166 | * |
| 167 | * @since 1.0 |
| 168 | */ |
| 169 | public function getFragment(); |
| 170 | |
| 171 | /** |
| 172 | * Checks whether the current URI is using HTTPS. |
| 173 | * |
| 174 | * @return boolean True if using SSL via HTTPS. |
| 175 | * |
| 176 | * @since 1.0 |
| 177 | */ |
| 178 | public function isSsl(); |
| 179 | } |