Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

Commit 8f7a4e2

Browse files
committed
Swap individual if statements with foreach loops.
1 parent f71b8f7 commit 8f7a4e2

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

src/Dsn.php

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,12 @@ protected function parseUrlArray($url)
239239

240240
$url = array_merge($this->uriKeys, $url);
241241

242-
if (isset($url['host'])) {
243-
$url['host'] = urldecode($url['host']);
244-
}
245-
246-
if (isset($url['user'])) {
247-
$url['user'] = urldecode($url['user']);
248-
}
242+
foreach (['host', 'user', 'pass'] as $key) {
243+
if (!isset($url[$key])) {
244+
continue;
245+
}
249246

250-
if (isset($url['pass'])) {
251-
$url['pass'] = urldecode($url['pass']);
247+
$url[$key] = urldecode($url[$key]);
252248
}
253249

254250
foreach ($url as $key => $val) {
@@ -301,16 +297,12 @@ protected function toUrlArray($data)
301297
{
302298
$url = array_intersect_key($data, $this->uriKeys);
303299

304-
if (isset($url['host'])) {
305-
$url['host'] = urlencode($url['host']);
306-
}
307-
308-
if (isset($url['user'])) {
309-
$url['user'] = urlencode($url['user']);
310-
}
300+
foreach (['host', 'user', 'pass'] as $key) {
301+
if (!isset($url[$key])) {
302+
continue;
303+
}
311304

312-
if (isset($url['pass'])) {
313-
$url['pass'] = urlencode($url['pass']);
305+
$url[$key] = urlencode($url[$key]);
314306
}
315307

316308
if ($url['adapter']) {

0 commit comments

Comments
 (0)