Skip to content

Commit

Permalink
Rename class PhoneNumberKit to PhoneNumberUtility (#798)
Browse files Browse the repository at this point in the history
* Rename class PhoneNumberKit to PhoneNumberUtility, move CountryCodePicker to root level

* Adapt Formatter.swift to the renaming

* Adapt PhoneNumber+Codable.swift to the renaming

* Adapt PartialFormatter.swift to the renaming

* Adapt PhoneNumberFormatter.swift to the renaming

* Adapt UI/PhoneNumberTextField.swift to the renaming

* Adapt UI/CountryCodePickerViewController.swift to the renaming

* Adapt PhoneNumber.swift to the renaming

* Adapt the tests to the renaming

* Adapt examples/PhoneBook to the renaming

* Adapt README.md to the renaming
  • Loading branch information
HeEAaD authored Aug 20, 2024
1 parent 14efcae commit 3704f7b
Show file tree
Hide file tree
Showing 16 changed files with 370 additions and 377 deletions.
38 changes: 19 additions & 19 deletions PhoneNumberKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 53;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -19,7 +19,7 @@
3420CF5E1BE8959F00FAE34F /* Formatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3420CF5D1BE8959F00FAE34F /* Formatter.swift */; };
3422D9BA1BE6A2D500867D02 /* ParseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3422D9B91BE6A2D500867D02 /* ParseManager.swift */; };
3424186F1BB6E5A000EE70E7 /* PhoneNumberKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 342418641BB6E5A000EE70E7 /* PhoneNumberKit.framework */; };
342418741BB6E5A000EE70E7 /* PhoneNumberKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342418731BB6E5A000EE70E7 /* PhoneNumberKitTests.swift */; };
342418741BB6E5A000EE70E7 /* PhoneNumberUtilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342418731BB6E5A000EE70E7 /* PhoneNumberUtilityTests.swift */; };
342418801BB705B500EE70E7 /* PhoneNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3424187F1BB705B500EE70E7 /* PhoneNumber.swift */; };
342418821BB70F5200EE70E7 /* PhoneNumberParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342418811BB70F5200EE70E7 /* PhoneNumberParser.swift */; };
342548F01BE7EED500FBE524 /* MetadataTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342548EF1BE7EED500FBE524 /* MetadataTypes.swift */; };
Expand All @@ -28,10 +28,10 @@
343B850D1C62A25600918E46 /* PhoneNumberTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 343B850B1C62A25600918E46 /* PhoneNumberTextField.swift */; };
34566C9A1BC112C500715E6B /* RegexManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34566C991BC112C500715E6B /* RegexManager.swift */; };
346922671BC01DCC0023482F /* MetadataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346922661BC01DCC0023482F /* MetadataManager.swift */; };
346922691BC023A60023482F /* PhoneNumberKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346922681BC023A60023482F /* PhoneNumberKit.swift */; };
346922691BC023A60023482F /* PhoneNumberUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346922681BC023A60023482F /* PhoneNumberUtility.swift */; };
346EF14E1C69C688008C7306 /* PartialFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346EF14D1C69C688008C7306 /* PartialFormatterTests.swift */; };
347209901BB80A69004DE6DA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3472098F1BB80A69004DE6DA /* Foundation.framework */; };
34776AA81BE2BF1100400790 /* PhoneNumberKitParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34776AA71BE2BF1100400790 /* PhoneNumberKitParsingTests.swift */; };
34776AA81BE2BF1100400790 /* PhoneNumberUtilityParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34776AA71BE2BF1100400790 /* PhoneNumberUtilityParsingTests.swift */; };
34AA66021BDD160B00467912 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AA66011BDD160B00467912 /* Constants.swift */; };
34AA66041BDD448B00467912 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34AA66031BDD448B00467912 /* CoreTelephony.framework */; };
34CA34522380307300788D7D /* PhoneNumberMetadata.json in Resources */ = {isa = PBXBuildFile; fileRef = A863BC9923801ABC00088460 /* PhoneNumberMetadata.json */; };
Expand Down Expand Up @@ -62,7 +62,7 @@
C6DF6C591D1B09DD00259F4B /* MetadataTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342548EF1BE7EED500FBE524 /* MetadataTypes.swift */; };
C6DF6C5A1D1B09DD00259F4B /* ParseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3422D9B91BE6A2D500867D02 /* ParseManager.swift */; };
C6DF6C5C1D1B09DD00259F4B /* PhoneNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3424187F1BB705B500EE70E7 /* PhoneNumber.swift */; };
C6DF6C5D1D1B09DD00259F4B /* PhoneNumberKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346922681BC023A60023482F /* PhoneNumberKit.swift */; };
C6DF6C5D1D1B09DD00259F4B /* PhoneNumberUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346922681BC023A60023482F /* PhoneNumberUtility.swift */; };
C6DF6C5E1D1B09DD00259F4B /* PhoneNumberParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342418811BB70F5200EE70E7 /* PhoneNumberParser.swift */; };
C6DF6C5F1D1B09DD00259F4B /* RegexManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34566C991BC112C500715E6B /* RegexManager.swift */; };
C6DF6CA81D1B145300259F4B /* PhoneNumberKit.h in Headers */ = {isa = PBXBuildFile; fileRef = C6DF6CA71D1B145300259F4B /* PhoneNumberKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -73,7 +73,7 @@
C6DF6CB71D1B159A00259F4B /* MetadataTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342548EF1BE7EED500FBE524 /* MetadataTypes.swift */; };
C6DF6CB81D1B159A00259F4B /* ParseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3422D9B91BE6A2D500867D02 /* ParseManager.swift */; };
C6DF6CBA1D1B159A00259F4B /* PhoneNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3424187F1BB705B500EE70E7 /* PhoneNumber.swift */; };
C6DF6CBB1D1B159A00259F4B /* PhoneNumberKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346922681BC023A60023482F /* PhoneNumberKit.swift */; };
C6DF6CBB1D1B159A00259F4B /* PhoneNumberUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346922681BC023A60023482F /* PhoneNumberUtility.swift */; };
C6DF6CBC1D1B159A00259F4B /* PhoneNumberParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342418811BB70F5200EE70E7 /* PhoneNumberParser.swift */; };
C6DF6CBD1D1B159A00259F4B /* RegexManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34566C991BC112C500715E6B /* RegexManager.swift */; };
C6DF6CD41D1B18CE00259F4B /* PhoneNumberKit.h in Headers */ = {isa = PBXBuildFile; fileRef = C6DF6CA71D1B145300259F4B /* PhoneNumberKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -84,7 +84,7 @@
C6DF6CDA1D1B18D800259F4B /* MetadataTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342548EF1BE7EED500FBE524 /* MetadataTypes.swift */; };
C6DF6CDB1D1B18D800259F4B /* ParseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3422D9B91BE6A2D500867D02 /* ParseManager.swift */; };
C6DF6CDD1D1B18D800259F4B /* PhoneNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3424187F1BB705B500EE70E7 /* PhoneNumber.swift */; };
C6DF6CDE1D1B18D800259F4B /* PhoneNumberKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346922681BC023A60023482F /* PhoneNumberKit.swift */; };
C6DF6CDE1D1B18D800259F4B /* PhoneNumberUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346922681BC023A60023482F /* PhoneNumberUtility.swift */; };
C6DF6CDF1D1B18D800259F4B /* PhoneNumberParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 342418811BB70F5200EE70E7 /* PhoneNumberParser.swift */; };
C6DF6CE01D1B18D800259F4B /* RegexManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34566C991BC112C500715E6B /* RegexManager.swift */; };
C9D81F822348025700B75AB7 /* PhoneNumberTextFieldTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D81F812348025700B75AB7 /* PhoneNumberTextFieldTests.swift */; };
Expand Down Expand Up @@ -114,7 +114,7 @@
342418641BB6E5A000EE70E7 /* PhoneNumberKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PhoneNumberKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
342418691BB6E5A000EE70E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3424186E1BB6E5A000EE70E7 /* PhoneNumberKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PhoneNumberKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
342418731BB6E5A000EE70E7 /* PhoneNumberKitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhoneNumberKitTests.swift; sourceTree = "<group>"; };
342418731BB6E5A000EE70E7 /* PhoneNumberUtilityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhoneNumberUtilityTests.swift; sourceTree = "<group>"; };
342418751BB6E5A000EE70E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3424187F1BB705B500EE70E7 /* PhoneNumber.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneNumber.swift; sourceTree = "<group>"; };
342418811BB70F5200EE70E7 /* PhoneNumberParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneNumberParser.swift; sourceTree = "<group>"; };
Expand All @@ -124,10 +124,10 @@
343B850B1C62A25600918E46 /* PhoneNumberTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PhoneNumberTextField.swift; path = UI/PhoneNumberTextField.swift; sourceTree = "<group>"; usesTabs = 0; };
34566C991BC112C500715E6B /* RegexManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegexManager.swift; sourceTree = "<group>"; };
346922661BC01DCC0023482F /* MetadataManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MetadataManager.swift; sourceTree = "<group>"; };
346922681BC023A60023482F /* PhoneNumberKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneNumberKit.swift; sourceTree = "<group>"; };
346922681BC023A60023482F /* PhoneNumberUtility.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneNumberUtility.swift; sourceTree = "<group>"; };
346EF14D1C69C688008C7306 /* PartialFormatterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartialFormatterTests.swift; sourceTree = "<group>"; };
3472098F1BB80A69004DE6DA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
34776AA71BE2BF1100400790 /* PhoneNumberKitParsingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneNumberKitParsingTests.swift; sourceTree = "<group>"; };
34776AA71BE2BF1100400790 /* PhoneNumberUtilityParsingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneNumberUtilityParsingTests.swift; sourceTree = "<group>"; };
34AA66011BDD160B00467912 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
34AA66031BDD448B00467912 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
34F26FBD2517DCB700B6AF4D /* Bundle+Resources.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Resources.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -230,7 +230,7 @@
children = (
C6DF6CA71D1B145300259F4B /* PhoneNumberKit.h */,
342418691BB6E5A000EE70E7 /* Info.plist */,
346922681BC023A60023482F /* PhoneNumberKit.swift */,
346922681BC023A60023482F /* PhoneNumberUtility.swift */,
A863BC9923801ABC00088460 /* PhoneNumberMetadata.json */,
340757841DA03A1700D493A0 /* Metadata */,
3422D9B91BE6A2D500867D02 /* ParseManager.swift */,
Expand All @@ -256,10 +256,10 @@
342418721BB6E5A000EE70E7 /* PhoneNumberKitTests */ = {
isa = PBXGroup;
children = (
342418731BB6E5A000EE70E7 /* PhoneNumberKitTests.swift */,
342418731BB6E5A000EE70E7 /* PhoneNumberUtilityTests.swift */,
D51A60AD27442EF50021EE7E /* PhoneNumber+CodableTests.swift */,
346EF14D1C69C688008C7306 /* PartialFormatterTests.swift */,
34776AA71BE2BF1100400790 /* PhoneNumberKitParsingTests.swift */,
34776AA71BE2BF1100400790 /* PhoneNumberUtilityParsingTests.swift */,
342418751BB6E5A000EE70E7 /* Info.plist */,
C9D81F812348025700B75AB7 /* PhoneNumberTextFieldTests.swift */,
);
Expand Down Expand Up @@ -514,7 +514,7 @@
343B850D1C62A25600918E46 /* PhoneNumberTextField.swift in Sources */,
5D14267D238F5842002DD197 /* CountryCodePickerViewController.swift in Sources */,
3417BD6B2210AC4900477EE7 /* MetadataParsing.swift in Sources */,
346922691BC023A60023482F /* PhoneNumberKit.swift in Sources */,
346922691BC023A60023482F /* PhoneNumberUtility.swift in Sources */,
343B850C1C62A25600918E46 /* PartialFormatter.swift in Sources */,
D51A60A9274416050021EE7E /* PhoneNumber+Codable.swift in Sources */,
3422D9BA1BE6A2D500867D02 /* ParseManager.swift in Sources */,
Expand All @@ -531,8 +531,8 @@
buildActionMask = 2147483647;
files = (
D51A60AE27442EF50021EE7E /* PhoneNumber+CodableTests.swift in Sources */,
34776AA81BE2BF1100400790 /* PhoneNumberKitParsingTests.swift in Sources */,
342418741BB6E5A000EE70E7 /* PhoneNumberKitTests.swift in Sources */,
34776AA81BE2BF1100400790 /* PhoneNumberUtilityParsingTests.swift in Sources */,
342418741BB6E5A000EE70E7 /* PhoneNumberUtilityTests.swift in Sources */,
346EF14E1C69C688008C7306 /* PartialFormatterTests.swift in Sources */,
C9D81F822348025700B75AB7 /* PhoneNumberTextFieldTests.swift in Sources */,
);
Expand All @@ -542,7 +542,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C6DF6C5D1D1B09DD00259F4B /* PhoneNumberKit.swift in Sources */,
C6DF6C5D1D1B09DD00259F4B /* PhoneNumberUtility.swift in Sources */,
C6B53DA71D94508400E607DD /* NSRegularExpression+Swift.swift in Sources */,
C6DF6C5A1D1B09DD00259F4B /* ParseManager.swift in Sources */,
C6DF6C5E1D1B09DD00259F4B /* PhoneNumberParser.swift in Sources */,
Expand All @@ -566,7 +566,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C6DF6CBB1D1B159A00259F4B /* PhoneNumberKit.swift in Sources */,
C6DF6CBB1D1B159A00259F4B /* PhoneNumberUtility.swift in Sources */,
C6B53DA51D944F8000E607DD /* NSRegularExpression+Swift.swift in Sources */,
C6DF6CB81D1B159A00259F4B /* ParseManager.swift in Sources */,
C6DF6CBC1D1B159A00259F4B /* PhoneNumberParser.swift in Sources */,
Expand All @@ -591,7 +591,7 @@
buildActionMask = 2147483647;
files = (
C6B53DA61D944F8000E607DD /* NSRegularExpression+Swift.swift in Sources */,
C6DF6CDE1D1B18D800259F4B /* PhoneNumberKit.swift in Sources */,
C6DF6CDE1D1B18D800259F4B /* PhoneNumberUtility.swift in Sources */,
C6DF6CDB1D1B18D800259F4B /* ParseManager.swift in Sources */,
C6DF6CDF1D1B18D800259F4B /* PhoneNumberParser.swift in Sources */,
C6DF6CD61D1B18D800259F4B /* Formatter.swift in Sources */,
Expand Down
4 changes: 0 additions & 4 deletions PhoneNumberKit/Formatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import Foundation
final class Formatter {
weak var regexManager: RegexManager?

init(phoneNumberKit: PhoneNumberKit) {
self.regexManager = phoneNumberKit.regexManager
}

init(regexManager: RegexManager) {
self.regexManager = regexManager
}
Expand Down
20 changes: 10 additions & 10 deletions PhoneNumberKit/PartialFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ import Foundation

/// Partial formatter
public final class PartialFormatter {
private let phoneNumberKit: PhoneNumberKit
private let utility: PhoneNumberUtility

weak var metadataManager: MetadataManager?
weak var parser: PhoneNumberParser?
weak var regexManager: RegexManager?

public convenience init(phoneNumberKit: PhoneNumberKit = PhoneNumberKit(),
defaultRegion: String = PhoneNumberKit.defaultRegionCode(),
public convenience init(utility: PhoneNumberUtility = PhoneNumberUtility(),
defaultRegion: String = PhoneNumberUtility.defaultRegionCode(),
withPrefix: Bool = true,
maxDigits: Int? = nil,
ignoreIntlNumbers: Bool = false) {
self.init(phoneNumberKit: phoneNumberKit,
regexManager: phoneNumberKit.regexManager,
metadataManager: phoneNumberKit.metadataManager,
parser: phoneNumberKit.parseManager.parser,
self.init(utility: utility,
regexManager: utility.regexManager,
metadataManager: utility.metadataManager,
parser: utility.parseManager.parser,
defaultRegion: defaultRegion,
withPrefix: withPrefix,
maxDigits: maxDigits,
ignoreIntlNumbers: ignoreIntlNumbers)
}

init(phoneNumberKit: PhoneNumberKit,
init(utility: PhoneNumberUtility,
regexManager: RegexManager,
metadataManager: MetadataManager,
parser: PhoneNumberParser, defaultRegion: String,
withPrefix: Bool = true,
maxDigits: Int? = nil,
ignoreIntlNumbers: Bool = false) {
self.phoneNumberKit = phoneNumberKit
self.utility = utility
self.regexManager = regexManager
self.metadataManager = metadataManager
self.parser = parser
Expand Down Expand Up @@ -80,7 +80,7 @@ public final class PartialFormatter {
public var currentRegion: String {
if ignoreIntlNumbers, currentMetadata?.codeID == "001" {
return defaultRegion
} else if self.phoneNumberKit.countryCode(for: self.defaultRegion) != 1 {
} else if self.utility.countryCode(for: self.defaultRegion) != 1 {
return currentMetadata?.codeID ?? "US"
} else {
return self.currentMetadata?.countryCode == 1 ?
Expand Down
Loading

0 comments on commit 3704f7b

Please sign in to comment.