Skip to content

Commit 82f6896

Browse files
authored
easier to read switch (#734)
1 parent 7aec2ad commit 82f6896

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

BeeKit/GoalExtensions.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import UIKit
33

44
extension Goal {
55
public var humanizedAutodata: String? {
6-
if self.autodata == "ifttt" { return "IFTTT" }
7-
if self.autodata == "api" { return "API" }
8-
if self.autodata == "apple" {
6+
guard let autodata, !autodata.isEmpty else { return nil }
7+
switch autodata {
8+
case "ifttt": return "IFTTT"
9+
case "api": return "API"
10+
case "apple":
911
let metric = HealthKitConfig.metrics.first(where: { $0.databaseString == self.healthKitMetric })
1012
return self.healthKitMetric == nil ? "Apple" : metric?.humanText
13+
default: return autodata.capitalized
1114
}
12-
if let autodata = self.autodata, autodata.count > 0 { return autodata.capitalized }
13-
return nil
1415
}
1516

1617
public var isDataProvidedAutomatically: Bool { return !(self.autodata ?? "").isEmpty }

0 commit comments

Comments
 (0)