Skip to content

Commit 271bcdd

Browse files
Mark Pospeselmpospese
authored andcommitted
[Issue-46] extract ternary operators to local variables
1 parent 4e2e875 commit 271bcdd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/YCoreUI/Extensions/UIKit/UIColor+rgbValue.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ public extension UIColor {
3434
let g = Int(round(comp.green * 255))
3535
let b = Int(round(comp.blue * 255))
3636
let isRGB = (r >= 0 && r <= 255) && (g >= 0 && g <= 255) && (b >= 0 && b <= 255)
37+
let prefix = prefix ?? ""
3738
let value = String(
3839
format: format,
3940
min(max(r, 0), 255),
4041
min(max(g, 0), 255),
4142
min(max(b, 0), 255)
4243
)
44+
let suffix = (isDebug && !isRGB) ? "⚠️" : ""
4345
if !isRGB && YCoreUI.isLoggingEnabled {
4446
YCoreUI.colorLogger.warning("Color \(self) falls outside of the sRGB color space.")
4547
}
46-
return "\(prefix ?? "")\(value)\(isDebug && !isRGB ? "⚠️" : "")"
48+
return "\(prefix)\(value)\(suffix)"
4749
}
4850
}

0 commit comments

Comments
 (0)