-
Notifications
You must be signed in to change notification settings - Fork 38
/
phone_number.go
54 lines (45 loc) · 1.21 KB
/
phone_number.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package faker
type FakePhoneNumber interface {
PhoneNumber() string // => "1-599-267-6597 x537"
CellPhone() string // => "+49-131-0003060"
AreaCode() string // => "903"
ExchangeCode() string // => "574"
SubscriberNumber(digits int) string // => "1512"
String() string // String is an alias for PhoneNumber.
}
type fakePhoneNumber struct{}
func PhoneNumber() FakePhoneNumber {
return fakePhoneNumber{}
}
func (p fakePhoneNumber) PhoneNumber() string {
return Numerify(Fetch("phone_number.formats"))
}
func (p fakePhoneNumber) CellPhone() string {
return Numerify(Fetch("cell_phone.formats"))
}
func (p fakePhoneNumber) AreaCode() string {
var res string
defer func() {
if err := recover(); err != nil {
res = ""
}
}()
res = Fetch("phone_number.area_code")
return res
}
func (p fakePhoneNumber) ExchangeCode() string {
var res string
defer func() {
if err := recover(); err != nil {
res = ""
}
}()
res = Fetch("phone_number.exchange_code")
return res
}
func (p fakePhoneNumber) SubscriberNumber(digits int) string {
return Number().Number(digits)
}
func (p fakePhoneNumber) String() string {
return p.PhoneNumber()
}