Skip to content

Commit c917dde

Browse files
authored
Improve Turkish phone numbers for E164 and landline support (#460)
1 parent 06532ac commit c917dde

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed

src/Faker/Provider/tr_TR/PhoneNumber.php

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,183 @@
44

55
class PhoneNumber extends \Faker\Provider\PhoneNumber
66
{
7+
/**
8+
* Mixed landline and mobile phone numbers valid for Turkey
9+
*
10+
* @see https://en.wikipedia.org/wiki/Telephone_numbers_in_Turkey
11+
*
12+
* @var string[]
13+
*/
714
protected static $formats = [
15+
'0212#######',
16+
'0216#######',
17+
'0222#######',
18+
'0224#######',
819
'050########',
920
'053########',
1021
'054########',
1122
'055########',
23+
'0 212 ### ## ##',
24+
'0 216 ### ## ##',
25+
'0 222 ### ## ##',
26+
'0 224 ### ## ##',
1227
'0 50# ### ## ##',
1328
'0 53# ### ## ##',
1429
'0 54# ### ## ##',
1530
'0 55# ### ## ##',
31+
'0 (212) ### ## ##',
32+
'0 (216) ### ## ##',
33+
'0 (222) ### ## ##',
34+
'0 (224) ### ## ##',
1635
'0 (50#) ### ## ##',
1736
'0 (53#) ### ## ##',
1837
'0 (54#) ### ## ##',
1938
'0 (55#) ### ## ##',
39+
'+90212#######',
40+
'+90216#######',
41+
'+90222#######',
42+
'+90224#######',
2043
'+9050########',
2144
'+9053########',
2245
'+9054########',
2346
'+9055########',
47+
'+90 212 ### ## ##',
48+
'+90 216 ### ## ##',
49+
'+90 222 ### ## ##',
50+
'+90 224 ### ## ##',
2451
'+90 50# ### ## ##',
2552
'+90 53# ### ## ##',
2653
'+90 54# ### ## ##',
2754
'+90 55# ### ## ##',
55+
'+90 (212) ### ## ##',
56+
'+90 (216) ### ## ##',
57+
'+90 (222) ### ## ##',
58+
'+90 (224) ### ## ##',
2859
'+90 (50#) ### ## ##',
2960
'+90 (53#) ### ## ##',
3061
'+90 (54#) ### ## ##',
3162
'+90 (55#) ### ## ##',
3263
];
64+
65+
/**
66+
* Mixed landline and mobile phone numbers in E164 format valid for Turkey
67+
*
68+
* @see https://en.wikipedia.org/wiki/Telephone_numbers_in_Turkey
69+
*
70+
* @var string[]
71+
*/
72+
protected static $e164Formats = [
73+
'+90212#######',
74+
'+90216#######',
75+
'+90222#######',
76+
'+90224#######',
77+
'+90226#######',
78+
'+90228#######',
79+
'+90232#######',
80+
'+90236#######',
81+
'+90242#######',
82+
'+90246#######',
83+
'+90248#######',
84+
'+90252#######',
85+
'+90256#######',
86+
'+90258#######',
87+
'+90262#######',
88+
'+90264#######',
89+
'+90266#######',
90+
'+90272#######',
91+
'+90274#######',
92+
'+90276#######',
93+
'+90282#######',
94+
'+90284#######',
95+
'+90286#######',
96+
'+90288#######',
97+
'+90312#######',
98+
'+90318#######',
99+
'+90322#######',
100+
'+90324#######',
101+
'+90326#######',
102+
'+90328#######',
103+
'+90332#######',
104+
'+90338#######',
105+
'+90342#######',
106+
'+90344#######',
107+
'+90346#######',
108+
'+90348#######',
109+
'+90352#######',
110+
'+90354#######',
111+
'+90356#######',
112+
'+90358#######',
113+
'+90362#######',
114+
'+90364#######',
115+
'+90366#######',
116+
'+90368#######',
117+
'+90370#######',
118+
'+90372#######',
119+
'+90374#######',
120+
'+90376#######',
121+
'+90378#######',
122+
'+90380#######',
123+
'+90382#######',
124+
'+90384#######',
125+
'+90386#######',
126+
'+90388#######',
127+
'+90412#######',
128+
'+90414#######',
129+
'+90416#######',
130+
'+90422#######',
131+
'+90424#######',
132+
'+90426#######',
133+
'+90428#######',
134+
'+90432#######',
135+
'+90434#######',
136+
'+90436#######',
137+
'+90438#######',
138+
'+90442#######',
139+
'+90446#######',
140+
'+90452#######',
141+
'+90454#######',
142+
'+90456#######',
143+
'+90458#######',
144+
'+90462#######',
145+
'+90464#######',
146+
'+90466#######',
147+
'+90472#######',
148+
'+90474#######',
149+
'+90476#######',
150+
'+90478#######',
151+
'+90482#######',
152+
'+90484#######',
153+
'+90486#######',
154+
'+90488#######',
155+
'+90501#######',
156+
'+90502#######',
157+
'+90503#######',
158+
'+90504#######',
159+
'+90505#######',
160+
'+90506#######',
161+
'+90507#######',
162+
'+90530#######',
163+
'+90531#######',
164+
'+90532#######',
165+
'+90533#######',
166+
'+90534#######',
167+
'+90535#######',
168+
'+90536#######',
169+
'+90537#######',
170+
'+90538#######',
171+
'+90539#######',
172+
'+90541#######',
173+
'+90542#######',
174+
'+90543#######',
175+
'+90544#######',
176+
'+90545#######',
177+
'+90546#######',
178+
'+90549#######',
179+
'+90551#######',
180+
'+90552#######',
181+
'+90553#######',
182+
'+90554#######',
183+
'+90555#######',
184+
'+90556#######',
185+
];
33186
}

test/Faker/Provider/tr_TR/PhoneNumberTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ public function testPhoneNumber()
2121
}
2222
}
2323

24+
public function testE164PhoneNumberFormat()
25+
{
26+
for ($i = 0; $i < 10; ++$i) {
27+
$number = $this->faker->e164PhoneNumber();
28+
self::assertMatchesRegularExpression('/^\+90\d{10}$/', $number);
29+
}
30+
}
31+
2432
protected function getProviders(): iterable
2533
{
2634
yield new PhoneNumber($this->faker);

0 commit comments

Comments
 (0)