Skip to content

Commit

Permalink
Apple/Nullable value (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
borut-t authored May 15, 2024
1 parent 4f4e763 commit 8915aca
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Sources/Apple/AppleAuthenticator+Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ public extension AppleAuthenticator {
public let nameComponents: PersonNameComponents?
public let email: Email
public let expiresAt: Date

public var name: String {
[nameComponents?.givenName, nameComponents?.familyName]
.compactMap { $0 }
.joined(separator: " ")

/// User full name represented by `givenName` and `familyName`
public var name: String? {
guard let givenName = nameComponents?.givenName else {
return nameComponents?.familyName
}
guard let familyName = nameComponents?.familyName else {
return givenName
}
return "\(givenName) \(familyName)"
}
}

Expand Down

0 comments on commit 8915aca

Please sign in to comment.