Skip to content

Commit 1661855

Browse files
committed
refactor: Make some code a bit more correct
- Use PHP_FLOAT_EPSILON for float comparaison - Simplify some getValueBool code Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
1 parent 0744d1c commit 1661855

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

apps/user_ldap/lib/User/DeletedUsersIndex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ public function markUser(string $ocName): void {
8585
}
8686

8787
public function isUserMarked(string $ocName): bool {
88-
return ($this->userConfig->getValueBool($ocName, 'user_ldap', 'isDeleted', false) === true);
88+
return $this->userConfig->getValueBool($ocName, 'user_ldap', 'isDeleted');
8989
}
9090
}

apps/weather_status/lib/Service/WeatherStatusService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ public function getLocation(): array {
285285
$address = $this->userConfig->getValueString($this->userId, Application::APP_ID, 'address');
286286
$mode = $this->userConfig->getValueInt($this->userId, Application::APP_ID, 'mode', self::MODE_MANUAL_LOCATION);
287287
return [
288-
'lat' => $lat === 0.0 ? '' : (string)$lat,
289-
'lon' => $lon === 0.0 ? '' : (string)$lon,
288+
'lat' => abs($lat) < PHP_FLOAT_EPSILON ? '' : (string)$lat,
289+
'lon' => abs($lon) < PHP_FLOAT_EPSILON ? '' : (string)$lon,
290290
'address' => $address,
291291
'mode' => $mode,
292292
];

0 commit comments

Comments
 (0)