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>
pull/55631/head
Carl Schwan 2 weeks ago
parent 0744d1cf6b
commit 1661855f5b
No known key found for this signature in database
GPG Key ID: 02325448204E452A
  1. 2
      apps/user_ldap/lib/User/DeletedUsersIndex.php
  2. 4
      apps/weather_status/lib/Service/WeatherStatusService.php

@ -85,6 +85,6 @@ class DeletedUsersIndex {
}
public function isUserMarked(string $ocName): bool {
return ($this->userConfig->getValueBool($ocName, 'user_ldap', 'isDeleted', false) === true);
return $this->userConfig->getValueBool($ocName, 'user_ldap', 'isDeleted');
}
}

@ -285,8 +285,8 @@ class WeatherStatusService {
$address = $this->userConfig->getValueString($this->userId, Application::APP_ID, 'address');
$mode = $this->userConfig->getValueInt($this->userId, Application::APP_ID, 'mode', self::MODE_MANUAL_LOCATION);
return [
'lat' => $lat === 0.0 ? '' : (string)$lat,
'lon' => $lon === 0.0 ? '' : (string)$lon,
'lat' => abs($lat) < PHP_FLOAT_EPSILON ? '' : (string)$lat,
'lon' => abs($lon) < PHP_FLOAT_EPSILON ? '' : (string)$lon,
'address' => $address,
'mode' => $mode,
];

Loading…
Cancel
Save