Skip to content

Commit e851e09

Browse files
Adobelsczechboy0
andauthored
Update Sources/Configuration/Providers/EnvironmentVariables/EnvironmentVariablesProvider.swift
Use a compact switch-based implementation for decodeBool. Co-authored-by: Honza Dvorsky <honza@apple.com>
1 parent b4cda9e commit e851e09

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Sources/Configuration/Providers/EnvironmentVariables/EnvironmentVariablesProvider.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,10 @@ public struct EnvironmentVariablesProvider: Sendable {
145145

146146
/// A decoder of bool values from a string
147147
static func decodeBool(from string: String) -> Bool? {
148-
let stringLowercased = string.lowercased()
149-
return if ["true", "false"].contains(stringLowercased) {
150-
stringLowercased == "true"
151-
} else if ["yes", "no"].contains(stringLowercased) {
152-
stringLowercased == "yes"
153-
} else if ["1", "0"].contains(stringLowercased) {
154-
stringLowercased == "1"
155-
} else {
156-
nil
148+
switch string.lowercased() {
149+
case "true", "yes", "1": true
150+
case "false", "no", "0": false
151+
default: nil
157152
}
158153
}
159154
}

0 commit comments

Comments
 (0)