Skip to content

Commit

Permalink
Fix psalm error
Browse files Browse the repository at this point in the history
  • Loading branch information
mstilkerich committed Oct 18, 2021
1 parent b4c86ac commit 9e60ae1
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions carddav.php
Original file line number Diff line number Diff line change
Expand Up @@ -1074,32 +1074,30 @@ private function getAddressbookSettingsFromPOST(string $abookId, ?string $preset

if (is_bool(self::ABOOK_TEMPLATE[$attr])) {
$result[$attr] = (bool) $value;
} else {
if (isset($value)) {
if ($attr == "refresh_time") {
try {
$result["refresh_time"] = self::parseTimeParameter($value);
} catch (\Exception $e) {
// will use the DB default for new addressbooks, or leave the value unchanged for existing
// ones
}
} elseif ($attr == "url") {
$value = trim($value);
if (!empty($value)) {
// FILTER_VALIDATE_URL requires the scheme component, default to https if not specified
if (strpos($value, "://") === false) {
$value = "https://$value";
}
}
$result["url"] = $value;
} elseif ($attr == "password") {
// Password is only updated if not empty
if (!empty($value)) {
$result["password"] = $value;
} elseif (is_string($value)) {
if ($attr == "refresh_time") {
try {
$result["refresh_time"] = self::parseTimeParameter($value);
} catch (\Exception $e) {
// will use the DB default for new addressbooks, or leave the value unchanged for existing
// ones
}
} elseif ($attr == "url") {
$value = trim($value);
if (!empty($value)) {
// FILTER_VALIDATE_URL requires the scheme component, default to https if not specified
if (strpos($value, "://") === false) {
$value = "https://$value";
}
} else {
$result[$attr] = $value;
}
$result["url"] = $value;
} elseif ($attr == "password") {
// Password is only updated if not empty
if (!empty($value)) {
$result["password"] = $value;
}
} else {
$result[$attr] = $value;
}
}
}
Expand Down

0 comments on commit 9e60ae1

Please sign in to comment.