line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# automatically generated file, don't edit |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# Copyright 2023 David Cantrell, derived from data from libphonenumber |
6
|
|
|
|
|
|
|
# http://code.google.com/p/libphonenumber/ |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
9
|
|
|
|
|
|
|
# you may not use this file except in compliance with the License. |
10
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
15
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
16
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
18
|
|
|
|
|
|
|
# limitations under the License. |
19
|
|
|
|
|
|
|
package Number::Phone::StubCountry::TH; |
20
|
2
|
|
|
2
|
|
1171
|
use base qw(Number::Phone::StubCountry); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
225
|
|
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
16
|
use strict; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
53
|
|
23
|
2
|
|
|
2
|
|
19
|
use warnings; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
70
|
|
24
|
2
|
|
|
2
|
|
13
|
use utf8; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
11
|
|
25
|
|
|
|
|
|
|
our $VERSION = 1.20230307181422; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $formatters = [ |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
'format' => '$1 $2 $3', |
30
|
|
|
|
|
|
|
'leading_digits' => '2', |
31
|
|
|
|
|
|
|
'national_rule' => '0$1', |
32
|
|
|
|
|
|
|
'pattern' => '(\\d)(\\d{3})(\\d{4})' |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
{ |
35
|
|
|
|
|
|
|
'format' => '$1 $2 $3', |
36
|
|
|
|
|
|
|
'leading_digits' => '[13-9]', |
37
|
|
|
|
|
|
|
'national_rule' => '0$1', |
38
|
|
|
|
|
|
|
'pattern' => '(\\d{2})(\\d{3})(\\d{3,4})' |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
{ |
41
|
|
|
|
|
|
|
'format' => '$1 $2 $3', |
42
|
|
|
|
|
|
|
'leading_digits' => '1', |
43
|
|
|
|
|
|
|
'pattern' => '(\\d{4})(\\d{3})(\\d{3})' |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
]; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $validators = { |
48
|
|
|
|
|
|
|
'fixed_line' => ' |
49
|
|
|
|
|
|
|
(?: |
50
|
|
|
|
|
|
|
1[0689]| |
51
|
|
|
|
|
|
|
2\\d| |
52
|
|
|
|
|
|
|
3[2-9]| |
53
|
|
|
|
|
|
|
4[2-5]| |
54
|
|
|
|
|
|
|
5[2-6]| |
55
|
|
|
|
|
|
|
7[3-7] |
56
|
|
|
|
|
|
|
)\\d{6} |
57
|
|
|
|
|
|
|
', |
58
|
|
|
|
|
|
|
'geographic' => ' |
59
|
|
|
|
|
|
|
(?: |
60
|
|
|
|
|
|
|
1[0689]| |
61
|
|
|
|
|
|
|
2\\d| |
62
|
|
|
|
|
|
|
3[2-9]| |
63
|
|
|
|
|
|
|
4[2-5]| |
64
|
|
|
|
|
|
|
5[2-6]| |
65
|
|
|
|
|
|
|
7[3-7] |
66
|
|
|
|
|
|
|
)\\d{6} |
67
|
|
|
|
|
|
|
', |
68
|
|
|
|
|
|
|
'mobile' => ' |
69
|
|
|
|
|
|
|
671[0-8]\\d{5}| |
70
|
|
|
|
|
|
|
(?: |
71
|
|
|
|
|
|
|
14| |
72
|
|
|
|
|
|
|
6[1-6]| |
73
|
|
|
|
|
|
|
[89]\\d |
74
|
|
|
|
|
|
|
)\\d{7} |
75
|
|
|
|
|
|
|
', |
76
|
|
|
|
|
|
|
'pager' => '', |
77
|
|
|
|
|
|
|
'personal_number' => '', |
78
|
|
|
|
|
|
|
'specialrate' => '(1900\\d{6})', |
79
|
|
|
|
|
|
|
'toll_free' => ' |
80
|
|
|
|
|
|
|
(?: |
81
|
|
|
|
|
|
|
001800\\d| |
82
|
|
|
|
|
|
|
1800 |
83
|
|
|
|
|
|
|
)\\d{6} |
84
|
|
|
|
|
|
|
', |
85
|
|
|
|
|
|
|
'voip' => '6[08]\\d{7}' |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
my %areanames = (); |
88
|
|
|
|
|
|
|
$areanames{th} = {"6618", "กรุงเทพ\/นนทบุรี\/ปทุมธานี\/สมุทรปราการ", |
89
|
|
|
|
|
|
|
"6676", "พังงา\/ภูเก็ต", |
90
|
|
|
|
|
|
|
"6632", "เพชรบุรี\/ประจวบคีรีขันธ์\/ราชบุรี", |
91
|
|
|
|
|
|
|
"6644", "บุรีรัมย์\/ชัยภูมิ\/นครราชสีมา\/สุรินทร์", |
92
|
|
|
|
|
|
|
"6656", "ชัยนาท\/นครสวรรค์\/เพชรบูรณ์\/พิจิตร\/อุทัยธานี", |
93
|
|
|
|
|
|
|
"6619", "กรุงเทพ\/นนทบุรี\/ปทุมธานี\/สมุทรปราการ", |
94
|
|
|
|
|
|
|
"6645", "อำนาจเจริญ\/ศรีสะเกษ\/อุบลราชธานี\/ยโสธร", |
95
|
|
|
|
|
|
|
"662", "กรุงเทพ\/นนทบุรี\/ปทุมธานี\/สมุทรปราการ", |
96
|
|
|
|
|
|
|
"6633", "ฉะเชิงเทรา\/ชลบุรี\/ระยอง", |
97
|
|
|
|
|
|
|
"6616", "กรุงเทพ\/นนทบุรี\/ปทุมธานี\/สมุทรปราการ", |
98
|
|
|
|
|
|
|
"6674", "พัทลุง\/สตูล\/สงขลา", |
99
|
|
|
|
|
|
|
"6654", "ลำปาง\/น่าน\/พะเยา\/แพร่", |
100
|
|
|
|
|
|
|
"6675", "กระบี่\/นครศรีธรรมราช\/ตรัง", |
101
|
|
|
|
|
|
|
"6655", "กำแพงเพชร\/พิษณุโลก\/สุโขทัย\/ตาก\/อุตรดิตถ์", |
102
|
|
|
|
|
|
|
"6637", "นครนายก\/ปราจีนบุรี\/สระแก้ว", |
103
|
|
|
|
|
|
|
"6643", "กาฬสินธุ์\/ขอนแก่น\/มหาสารคาม\/ร้อยเอ็ด", |
104
|
|
|
|
|
|
|
"6652", "เชียงใหม่\/เชียงราย\/ลำพูน\/แม่ฮ่องสอน", |
105
|
|
|
|
|
|
|
"6610", "กรุงเทพ\/นนทบุรี\/ปทุมธานี\/สมุทรปราการ", |
106
|
|
|
|
|
|
|
"6636", "ลพบุรี\/สระบุรี\/สิงห์บุรี", |
107
|
|
|
|
|
|
|
"6653", "เชียงใหม่\/เชียงราย\/ลำพูน\/แม่ฮ่องสอน", |
108
|
|
|
|
|
|
|
"6673", "นราธิวาส\/ปัตตานี\/ยะลา", |
109
|
|
|
|
|
|
|
"6638", "ฉะเชิงเทรา\/ชลบุรี\/ระยอง", |
110
|
|
|
|
|
|
|
"6642", "เลย\/มุกดาหาร\/นครพนม\/หนองคาย\/สกลนคร\/อุดรธานี", |
111
|
|
|
|
|
|
|
"6634", "กาญจนบุรี\/นครปฐม\/สมุทรสาคร\/สมุทรสงคราม", |
112
|
|
|
|
|
|
|
"6677", "ชุมพร\/ระนอง\/สุราษฎร์ธานี", |
113
|
|
|
|
|
|
|
"6635", "อ่างทอง\/พระนครศรีอยุธยา\/สุพรรณบุรี", |
114
|
|
|
|
|
|
|
"6639", "จันทบุรี\/ตราด",}; |
115
|
|
|
|
|
|
|
$areanames{en} = {"6634", "Kanchanaburi\/Nakhon\ Pathom\/Samut\ Sakhon\/Samut\ Songkhram", |
116
|
|
|
|
|
|
|
"6638", "Chachoengsao\/Chon\ Buri\/Rayong", |
117
|
|
|
|
|
|
|
"6642", "Loei\/Mukdahan\/Nakhon\ Phanom\/Nong\ Khai\/Sakon\ Nakhon\/Udon\ Thani", |
118
|
|
|
|
|
|
|
"6673", "Narathiwat\/Pattani\/Yala", |
119
|
|
|
|
|
|
|
"6653", "Chiang\ Mai\/Chiang\ Rai\/Lamphun\/Mae\ Hong\ Son", |
120
|
|
|
|
|
|
|
"6639", "Chanthaburi\/Trat", |
121
|
|
|
|
|
|
|
"6635", "Ang\ Thong\/Phra\ Nakhon\ Si\ Ayutthaya\/Suphan\ Buri", |
122
|
|
|
|
|
|
|
"6677", "Chumphon\/Ranong\/Surat\ Thani", |
123
|
|
|
|
|
|
|
"6636", "Lop\ Buri\/Saraburi\/Sing\ Buri", |
124
|
|
|
|
|
|
|
"6652", "Chiang\ Mai\/Chiang\ Rai\/Lamphun\/Mae\ Hong\ Son", |
125
|
|
|
|
|
|
|
"6610", "Bangkok\/Nonthaburi\/Pathum\ Thani\/Samut\ Prakan", |
126
|
|
|
|
|
|
|
"6643", "Kalasin\/Khon\ Kaen\/Maha\ Sarakham\/Roi\ Et", |
127
|
|
|
|
|
|
|
"6654", "Lampang\/Nan\/Phayao\/Phrae", |
128
|
|
|
|
|
|
|
"6674", "Phatthalung\/Satun\/Songkhla", |
129
|
|
|
|
|
|
|
"6616", "Bangkok\/Nonthaburi\/Pathum\ Thani\/Samut\ Prakan", |
130
|
|
|
|
|
|
|
"6633", "Chachoengsao\/Chon\ Buri\/Rayong", |
131
|
|
|
|
|
|
|
"6655", "Kamphaeng\ Phet\/Phitsanulok\/Sukhothai\/Tak\/Uttaradit", |
132
|
|
|
|
|
|
|
"6637", "Nakhon\ Nayok\/Prachin\ Buri\/Sa\ Kaeo", |
133
|
|
|
|
|
|
|
"6675", "Krabi\/Nakhon\ Si\ Thammarat\/Trang", |
134
|
|
|
|
|
|
|
"6644", "Buri\ Ram\/Chaiyaphum\/Nakhon\ Ratchasima\/Surin", |
135
|
|
|
|
|
|
|
"6656", "Chai\ Nat\/Nakhon\ Sawan\/Phetchabun\/Phichit\/Uthai\ Thani", |
136
|
|
|
|
|
|
|
"6632", "Phetchaburi\/Prachuap\ Khiri\ Khan\/Ratchaburi", |
137
|
|
|
|
|
|
|
"6676", "Phang\ Nga\/Phuket", |
138
|
|
|
|
|
|
|
"6618", "Bangkok\/Nonthaburi\/Pathum\ Thani\/Samut\ Prakan", |
139
|
|
|
|
|
|
|
"662", "Bangkok\/Nonthaburi\/Pathum\ Thani\/Samut\ Prakan", |
140
|
|
|
|
|
|
|
"6619", "Bangkok\/Nonthaburi\/Pathum\ Thani\/Samut\ Prakan", |
141
|
|
|
|
|
|
|
"6645", "Amnat\ Charoen\/Si\ Sa\ Ket\/Ubon\ Ratchathani\/Yasothon",}; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub new { |
144
|
16
|
|
|
16
|
1
|
43
|
my $class = shift; |
145
|
16
|
|
|
|
|
22
|
my $number = shift; |
146
|
16
|
|
|
|
|
106
|
$number =~ s/(^\+66|\D)//g; |
147
|
16
|
|
|
|
|
89
|
my $self = bless({ country_code => '66', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class); |
148
|
16
|
100
|
|
|
|
74
|
return $self if ($self->is_valid()); |
149
|
1
|
|
|
|
|
3
|
$number =~ s/^(?:0)//; |
150
|
1
|
|
|
|
|
11
|
$self = bless({ country_code => '66', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class); |
151
|
1
|
50
|
|
|
|
11
|
return $self->is_valid() ? $self : undef; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
1; |