Skip to content

Commit 55b5376

Browse files
committed
Url: updated phpDoc
1 parent e126517 commit 55b5376

File tree

1 file changed

+21
-74
lines changed

1 file changed

+21
-74
lines changed

src/Http/Url.php

+21-74
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
/**
16-
* URI Syntax (RFC 3986).
16+
* Mutable representation of a URL.
1717
*
1818
* <pre>
1919
* scheme user password host port basePath relativeUrl
@@ -25,12 +25,6 @@
2525
* authority path query fragment
2626
* </pre>
2727
*
28-
* - authority: [user[:password]@]host[:port]
29-
* - hostUrl: http://user:[email protected]:8042
30-
* - basePath: /en/ (everything before relative URI not including the script name)
31-
* - baseUrl: http://user:[email protected]:8042/en/
32-
* - relativeUrl: manual.php
33-
*
3428
* @property string $scheme
3529
* @property string $user
3630
* @property string $password
@@ -56,8 +50,6 @@ class Url implements \JsonSerializable
5650
'http' => 80,
5751
'https' => 443,
5852
'ftp' => 21,
59-
'news' => 119,
60-
'nntp' => 119,
6153
];
6254

6355
/** @var string */
@@ -116,80 +108,64 @@ public function __construct($url = null)
116108

117109

118110
/**
119-
* Sets the scheme part of URI.
120111
* @return static
121112
*/
122-
public function setScheme(string $value)
113+
public function setScheme(string $scheme)
123114
{
124-
$this->scheme = $value;
115+
$this->scheme = $scheme;
125116
return $this;
126117
}
127118

128119

129-
/**
130-
* Returns the scheme part of URI.
131-
*/
132120
public function getScheme(): string
133121
{
134122
return $this->scheme;
135123
}
136124

137125

138126
/**
139-
* Sets the user name part of URI.
140127
* @return static
141128
*/
142-
public function setUser(string $value)
129+
public function setUser(string $user)
143130
{
144-
$this->user = $value;
131+
$this->user = $user;
145132
return $this;
146133
}
147134

148135

149-
/**
150-
* Returns the user name part of URI.
151-
*/
152136
public function getUser(): string
153137
{
154138
return $this->user;
155139
}
156140

157141

158142
/**
159-
* Sets the password part of URI.
160143
* @return static
161144
*/
162-
public function setPassword(string $value)
145+
public function setPassword(string $password)
163146
{
164-
$this->password = $value;
147+
$this->password = $password;
165148
return $this;
166149
}
167150

168151

169-
/**
170-
* Returns the password part of URI.
171-
*/
172152
public function getPassword(): string
173153
{
174154
return $this->password;
175155
}
176156

177157

178158
/**
179-
* Sets the host part of URI.
180159
* @return static
181160
*/
182-
public function setHost(string $value)
161+
public function setHost(string $host)
183162
{
184-
$this->host = $value;
163+
$this->host = $host;
185164
$this->setPath($this->path);
186165
return $this;
187166
}
188167

189168

190-
/**
191-
* Returns the host part of URI.
192-
*/
193169
public function getHost(): string
194170
{
195171
return $this->host;
@@ -208,77 +184,64 @@ public function getDomain(int $level = 2): string
208184

209185

210186
/**
211-
* Sets the port part of URI.
212187
* @return static
213188
*/
214-
public function setPort(int $value)
189+
public function setPort(int $port)
215190
{
216-
$this->port = $value;
191+
$this->port = $port;
217192
return $this;
218193
}
219194

220195

221-
/**
222-
* Returns the port part of URI.
223-
*/
224196
public function getPort(): ?int
225197
{
226198
return $this->port ?: (self::$defaultPorts[$this->scheme] ?? null);
227199
}
228200

229201

230202
/**
231-
* Sets the path part of URI.
232203
* @return static
233204
*/
234-
public function setPath(string $value)
205+
public function setPath(string $path)
235206
{
236-
$this->path = $value;
207+
$this->path = $path;
237208
if ($this->host && substr($this->path, 0, 1) !== '/') {
238209
$this->path = '/' . $this->path;
239210
}
240211
return $this;
241212
}
242213

243214

244-
/**
245-
* Returns the path part of URI.
246-
*/
247215
public function getPath(): string
248216
{
249217
return $this->path;
250218
}
251219

252220

253221
/**
254-
* Sets the query part of URI.
255222
* @param string|array $value
256223
* @return static
257224
*/
258-
public function setQuery($value)
225+
public function setQuery($query)
259226
{
260-
$this->query = is_array($value) ? $value : self::parseQuery($value);
227+
$this->query = is_array($query) ? $query : self::parseQuery($query);
261228
return $this;
262229
}
263230

264231

265232
/**
266-
* Appends the query part of URI.
267233
* @param string|array $value
268234
* @return static
269235
*/
270-
public function appendQuery($value)
236+
public function appendQuery($query)
271237
{
272-
$this->query = is_array($value)
273-
? $value + $this->query
274-
: self::parseQuery($this->getQuery() . '&' . $value);
238+
$this->query = is_array($query)
239+
? $query + $this->query
240+
: self::parseQuery($this->getQuery() . '&' . $query);
275241
return $this;
276242
}
277243

278244

279-
/**
280-
* Returns the query part of URI.
281-
*/
282245
public function getQuery(): string
283246
{
284247
return http_build_query($this->query, '', '&', PHP_QUERY_RFC3986);
@@ -315,28 +278,21 @@ public function setQueryParameter(string $name, $value)
315278

316279

317280
/**
318-
* Sets the fragment part of URI.
319281
* @return static
320282
*/
321-
public function setFragment(string $value)
283+
public function setFragment(string $fragment)
322284
{
323-
$this->fragment = $value;
285+
$this->fragment = $fragment;
324286
return $this;
325287
}
326288

327289

328-
/**
329-
* Returns the fragment part of URI.
330-
*/
331290
public function getFragment(): string
332291
{
333292
return $this->fragment;
334293
}
335294

336295

337-
/**
338-
* Returns the entire URI including query string and fragment.
339-
*/
340296
public function getAbsoluteUrl(): string
341297
{
342298
return $this->getHostUrl() . $this->path
@@ -372,28 +328,19 @@ public function getHostUrl(): string
372328
}
373329

374330

375-
/**
376-
* Returns the base-path.
377-
*/
378331
public function getBasePath(): string
379332
{
380333
$pos = strrpos($this->path, '/');
381334
return $pos === false ? '' : substr($this->path, 0, $pos + 1);
382335
}
383336

384337

385-
/**
386-
* Returns the base-URI.
387-
*/
388338
public function getBaseUrl(): string
389339
{
390340
return $this->getHostUrl() . $this->getBasePath();
391341
}
392342

393343

394-
/**
395-
* Returns the relative-URI.
396-
*/
397344
public function getRelativeUrl(): string
398345
{
399346
return substr($this->getAbsoluteUrl(), strlen($this->getBaseUrl()));

0 commit comments

Comments
 (0)