forked from davideme/libphonenumber-for-PHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PhoneMetadata.php
720 lines (579 loc) · 16.6 KB
/
PhoneMetadata.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
<?php
namespace libphonenumber;
class PhoneMetadata {
/**
* @var string
*/
private $id = NULL;
/**
*
* @return boolean
*/
public function hasId() {
return isset($this->id);
}
/**
*
* @return string
*/
public function getId() {
return $this->id;
}
/**
*
* @param string $value
* @return PhoneMetadata
*/
public function setId($value) {
$this->id = $value;
return $this;
}
/**
*
* @var int
*/
private $countryCode = NULL;
/**
*
* @return boolean
*/
public function hasCountryCode() {
return isset($this->countryCode);
}
/**
*
* @return int
*/
public function getCountryCode() {
return $this->countryCode;
}
/**
*
* @param int $value
* @return PhoneMetadata
*/
public function setCountryCode($value) {
$this->countryCode = $value;
return $this;
}
private $leadingDigits = NULL;
public function hasLeadingDigits() {
return isset($this->leadingDigits);
}
public function getLeadingDigits() {
return $this->leadingDigits;
}
public function setLeadingDigits($value) {
$this->leadingDigits = $value;
return $this;
}
private $internationalPrefix = NULL;
public function hasInternationalPrefix() {
return isset($this->internationalPrefix);
}
public function getInternationalPrefix() {
return $this->internationalPrefix;
}
public function setInternationalPrefix($value) {
$this->internationalPrefix = $value;
return $this;
}
private $preferredInternationalPrefix = NULL;
public function hasPreferredInternationalPrefix() {
return isset($this->preferredInternationalPrefix);
}
public function getPreferredInternationalPrefix() {
return $this->preferredInternationalPrefix;
}
public function setPreferredInternationalPrefix($value) {
$this->preferredInternationalPrefix = $value;
return $this;
}
private $nationalPrefixForParsing = NULL;
public function hasNationalPrefixForParsing() {
return isset($this->nationalPrefixForParsing);
}
public function getNationalPrefixForParsing() {
return $this->nationalPrefixForParsing;
}
public function setNationalPrefixForParsing($value) {
$this->nationalPrefixForParsing = $value;
return $this;
}
private $nationalPrefixTransformRule = NULL;
public function hasNationalPrefixTransformRule() {
return isset($this->nationalPrefixTransformRule);
}
public function getNationalPrefixTransformRule() {
return $this->nationalPrefixTransformRule;
}
public function setNationalPrefixTransformRule($value) {
$this->nationalPrefixTransformRule = $value;
return $this;
}
private $nationalPrefix = NULL;
public function hasNationalPrefix() {
return isset($this->nationalPrefix);
}
public function getNationalPrefix() {
return $this->nationalPrefix;
}
public function setNationalPrefix($value) {
$this->nationalPrefix = $value;
return $this;
}
private $preferredExtnPrefix = NULL;
public function hasPreferredExtnPrefix() {
return isset($this->preferredExtnPrefix);
}
public function getPreferredExtnPrefix() {
return $this->preferredExtnPrefix;
}
public function setPreferredExtnPrefix($value) {
$this->preferredExtnPrefix = $value;
return $this;
}
private $mainCountryForCode = NULL;
public function hasMainCountryForCode() {
return isset($this->mainCountryForCode);
}
public function isMainCountryForCode() {
return $this->mainCountryForCode;
}
// Method that lets this class have the same interface as the one generated by Protocol Buffers
// which is used by C++ build tools.
public function getMainCountryForCode() {
return $this->mainCountryForCode;
}
public function setMainCountryForCode($value) {
$this->mainCountryForCode = $value;
return $this;
}
private $leadingZeroPossible = NULL;
public function hasLeadingZeroPossible() {
return isset($this->leadingZeroPossible);
}
public function isLeadingZeroPossible() {
return $this->leadingZeroPossible;
}
public function setLeadingZeroPossible($value) {
$this->leadingZeroPossible = $value;
return $this;
}
private $generalDesc = null;
public function hasGeneralDesc() {
return isset($this->generalDesc);
}
/**
*
* @return PhoneNumberDesc
*/
public function getGeneralDesc() {
return $this->generalDesc;
}
public function setGeneralDesc(PhoneNumberDesc $value) {
$this->generalDesc = $value;
return $this;
}
/**
*
* @var PhoneNumberDesc
*/
private $mobile = null;
public function hasMobile() {
return isset($this->mobile);
}
/**
*
* @return PhoneNumberDesc
*/
public function getMobile() {
return $this->mobile;
}
public function setMobile(PhoneNumberDesc $value) {
$this->mobile = $value;
return $this;
}
private $premiumRate = null;
public function hasPremiumRate() {
return isset($this->premiumRate);
}
public function getPremiumRate() {
return $this->premiumRate;
}
public function setPremiumRate(PhoneNumberDesc $value) {
$this->premiumRate = $value;
return $this;
}
private $fixedLine = null;
public function hasFixedLine() {
return isset($this->fixedLine);
}
public function getFixedLine() {
return $this->fixedLine;
}
public function setFixedLine(PhoneNumberDesc $value) {
$this->fixedLine = $value;
return $this;
}
private $sameMobileAndFixedLinePattern = NULL;
public function hasSameMobileAndFixedLinePattern() {
return isset($this->sameMobileAndFixedLinePattern);
}
public function isSameMobileAndFixedLinePattern() {
return $this->sameMobileAndFixedLinePattern;
}
public function setSameMobileAndFixedLinePattern($value) {
$this->sameMobileAndFixedLinePattern = $value;
return $this;
}
private $numberFormat = array();
public function numberFormats() {
return $this->numberFormat;
}
public function numberFormatSize() {
return count($this->numberFormat);
}
public function getNumberFormat($index) {
return $this->numberFormat[$index];
}
public function addNumberFormat(NumberFormat $value) {
$this->numberFormat[] = $value;
return $this;
}
private $tollFree = NULL;
public function hasTollFree() {
return isset($this->tollFree);
}
public function getTollFree() {
return $this->tollFree;
}
public function setTollFree(PhoneNumberDesc $value) {
$this->tollFree = $value;
return $this;
}
private $sharedCost = null;
public function hasSharedCost() {
return isset($this->sharedCost);
}
public function getSharedCost() {
return $this->sharedCost;
}
public function setSharedCost(PhoneNumberDesc $value) {
$this->sharedCost = $value;
return $this;
}
/*
// required PhoneNumberDesc personal_number = 7;
private boolean hasPersonalNumber;
private PhoneNumberDesc personalNumber_ = null;
public boolean hasPersonalNumber() { return hasPersonalNumber; }
public PhoneNumberDesc getPersonalNumber() { return personalNumber_; }
public PhoneMetadata setPersonalNumber(PhoneNumberDesc value) {
if (value == null) {
throw new NullPointerException();
}
hasPersonalNumber = true;
personalNumber_ = $value;
return this;
}
// required PhoneNumberDesc voip = 8;
private boolean hasVoip;
private PhoneNumberDesc voip_ = null;
public boolean hasVoip() { return hasVoip; }
public PhoneNumberDesc getVoip() { return voip_; }
public PhoneMetadata setVoip(PhoneNumberDesc value) {
if (value == null) {
throw new NullPointerException();
}
hasVoip = true;
voip_ = $value;
return this;
}
// required PhoneNumberDesc pager = 21;
private boolean hasPager;
private PhoneNumberDesc pager_ = null;
public boolean hasPager() { return hasPager; }
public PhoneNumberDesc getPager() { return pager_; }
public PhoneMetadata setPager(PhoneNumberDesc value) {
if (value == null) {
throw new NullPointerException();
}
hasPager = true;
pager_ = $value;
return this;
}
// required PhoneNumberDesc uan = 25;
private boolean hasUan;
private PhoneNumberDesc uan_ = null;
public boolean hasUan() { return hasUan; }
public PhoneNumberDesc getUan() { return uan_; }
public PhoneMetadata setUan(PhoneNumberDesc value) {
if (value == null) {
throw new NullPointerException();
}
hasUan = true;
uan_ = $value;
return this;
}
// required PhoneNumberDesc voicemail = 28;
private boolean hasVoicemail;
private PhoneNumberDesc voicemail_ = null;
public boolean hasVoicemail() { return hasVoicemail; }
public PhoneNumberDesc getVoicemail() { return voicemail_; }
public PhoneMetadata setVoicemail(PhoneNumberDesc value) {
if (value == null) {
throw new NullPointerException();
}
hasVoicemail = true;
voicemail_ = $value;
return this;
}
// required PhoneNumberDesc emergency = 27;
private boolean hasEmergency;
private PhoneNumberDesc emergency_ = null;
public boolean hasEmergency() { return hasEmergency; }
public PhoneNumberDesc getEmergency() { return emergency_; }
public PhoneMetadata setEmergency(PhoneNumberDesc value) {
if (value == null) {
throw new NullPointerException();
}
hasEmergency = true;
emergency_ = $value;
return this;
}
*/
private $noInternationalDialling = null;
public function hasNoInternationalDialling() {
return isset($this->noInternationalDialling);
}
public function getNoInternationalDialling() {
return $this->noInternationalDialling;
}
public function setNoInternationalDialling(PhoneNumberDesc $value) {
$this->noInternationalDialling = $value;
return $this;
}
/**
*
* @var NumberFormat
*/
private $intlNumberFormat = array();
public function intlNumberFormats() {
return $this->intlNumberFormat;
}
public function intlNumberFormatSize() {
return count($this->intlNumberFormat);
}
public function getIntlNumberFormat($index) {
return $this->intlNumberFormat[$index];
}
public function addIntlNumberFormat(NumberFormat $value) {
$this->intlNumberFormat[] = $value;
return $this;
}
public function clearIntlNumberFormat() {
$this->intlNumberFormat = array();
return $this;
}
public function toArray() {
$output = array();
if ($this->hasGeneralDesc()) {
$output['generalDesc'] = $this->getGeneralDesc()->toArray();
}
if ($this->hasFixedLine()) {
$output['fixedLine'] = $this->getFixedLine()->toArray();
}
if ($this->hasMobile()) {
$output['mobile'] = $this->getMobile()->toArray();
}
if ($this->hasTollFree()) {
$output['tollFree'] = $this->getTollFree()->toArray();
}
if ($this->hasPremiumRate()) {
$output['premiumRate'] = $this->getPremiumRate()->toArray();
}
if ($this->hasPremiumRate()) {
$output['premiumRate'] = $this->getPremiumRate()->toArray();
}
if ($this->hasSharedCost()) {
$output['sharedCost'] = $this->getSharedCost()->toArray();
}
/*
objectOutput.writeBoolean(hasPersonalNumber);
if (hasPersonalNumber) {
personalNumber_.writeExternal(objectOutput);
}
objectOutput.writeBoolean(hasVoip);
if (hasVoip) {
voip_.writeExternal(objectOutput);
}
objectOutput.writeBoolean(hasPager);
if (hasPager) {
pager_.writeExternal(objectOutput);
}
objectOutput.writeBoolean(hasUan);
if (hasUan) {
uan_.writeExternal(objectOutput);
}
objectOutput.writeBoolean(hasVoicemail);
if (hasVoicemail) {
voicemail_.writeExternal(objectOutput);
}
objectOutput.writeBoolean(hasEmergency);
if (hasEmergency) {
emergency_.writeExternal(objectOutput);
}
*/
if ($this->hasNoInternationalDialling()) {
$output['noInternationalDialling'] = $this->getNoInternationalDialling()->toArray();
}
$output['id'] = $this->getId();
$output['countryCode'] = $this->getCountryCode();
$output['internationalPrefix'] = $this->getInternationalPrefix();
if ($this->hasPreferredInternationalPrefix()) {
$output['preferredInternationalPrefix'] = $this->getPreferredInternationalPrefix();
}
if ($this->hasNationalPrefix()) {
$output['nationalPrefix'] = $this->getNationalPrefix();
}
if ($this->hasPreferredExtnPrefix()) {
$output['preferredExtnPrefix'] = $this->getPreferredExtnPrefix();
}
if ($this->hasNationalPrefixForParsing()) {
$output['nationalPrefixForParsing'] = $this->getNationalPrefixForParsing();
}
if ($this->hasNationalPrefixTransformRule()) {
$output['nationalPrefixTransformRule'] = $this->getNationalPrefixTransformRule();
}
$output['sameMobileAndFixedLinePattern'] = $this->isSameMobileAndFixedLinePattern();
$output['numberFormat'] = array();
foreach ($this->numberFormats() as $numberFormat) {
/* @var $numberFormat NumberFormat */
$output['numberFormat'][] = $numberFormat->toArray();
}
$output['intlNumberFormat'] = array();
foreach ($this->intlNumberFormats() as $intlNumberFormat) {
/* @var $numberFormat NumberFormat */
$output['intlNumberFormat'][] = $intlNumberFormat->toArray();
}
$output['mainCountryForCode'] = $this->getMainCountryForCode();
if ($this->hasLeadingDigits()) {
$output['leadingDigits'] = $this->getLeadingDigits();
}
$output['leadingZeroPossible'] = $this->isLeadingZeroPossible();
return $output;
}
public function fromArray(array $input) {
if (isset($input['generalDesc'])) {
$desc = new PhoneNumberDesc();
$this->setGeneralDesc($desc->fromArray($input['generalDesc']));
}
if (isset($input['fixedLine'])) {
$desc = new PhoneNumberDesc();
$this->setFixedLine($desc->fromArray($input['fixedLine']));
}
if (isset($input['mobile'])) {
$desc = new PhoneNumberDesc();
$this->setMobile($desc->fromArray($input['mobile']));
}
if (isset($input['tollFree'])) {
$desc = new PhoneNumberDesc();
$this->setTollFree($desc->fromArray($input['tollFree']));
}
if (isset($input['premiumRate'])) {
$desc = new PhoneNumberDesc();
$this->setPremiumRate($desc->fromArray($input['premiumRate']));
}
if (isset($input['sharedCost'])) {
$desc = new PhoneNumberDesc();
$this->setSharedCost($desc->fromArray($input['sharedCost']));
}
/*
hasDesc = objectInput.readBoolean();
if (hasDesc) {
PhoneNumberDesc desc = new PhoneNumberDesc();
desc.readExternal(objectInput);
setPersonalNumber(desc);
}
hasDesc = objectInput.readBoolean();
if (hasDesc) {
PhoneNumberDesc desc = new PhoneNumberDesc();
desc.readExternal(objectInput);
setVoip(desc);
}
hasDesc = objectInput.readBoolean();
if (hasDesc) {
PhoneNumberDesc desc = new PhoneNumberDesc();
desc.readExternal(objectInput);
setPager(desc);
}
hasDesc = objectInput.readBoolean();
if (hasDesc) {
PhoneNumberDesc desc = new PhoneNumberDesc();
desc.readExternal(objectInput);
setUan(desc);
}
hasDesc = objectInput.readBoolean();
if (hasDesc) {
PhoneNumberDesc desc = new PhoneNumberDesc();
desc.readExternal(objectInput);
setVoicemail(desc);
}
hasDesc = objectInput.readBoolean();
if (hasDesc) {
PhoneNumberDesc desc = new PhoneNumberDesc();
desc.readExternal(objectInput);
setEmergency(desc);
}
*/
if (isset($input['noInternationalDialling'])) {
$desc = new PhoneNumberDesc();
$this->setNoInternationalDialling($desc->fromArray($input['noInternationalDialling']));
}
$this->setId($input['id']);
$this->setCountryCode($input['countryCode']);
$this->setInternationalPrefix($input['internationalPrefix']);
if (isset($input['preferredInternationalPrefix'])) {
$this->setPreferredInternationalPrefix($input['preferredInternationalPrefix']);
}
if (isset($input['nationalPrefix'])) {
$this->setNationalPrefix($input['nationalPrefix']);
}
if (isset($input['nationalPrefix'])) {
$this->setNationalPrefix($input['nationalPrefix']);
}
if (isset($input['preferredExtnPrefix'])) {
$this->setPreferredExtnPrefix($input['preferredExtnPrefix']);
}
if (isset($input['nationalPrefixForParsing'])) {
$this->setNationalPrefixForParsing($input['nationalPrefixForParsing']);
}
if (isset($input['nationalPrefixTransformRule'])) {
$this->setNationalPrefixTransformRule($input['nationalPrefixTransformRule']);
}
/*
setSameMobileAndFixedLinePattern(objectInput.readBoolean());
*/
foreach ($input['numberFormat'] as $numberFormatElt) {
$numberFormat = new NumberFormat();
$numberFormat->fromArray($numberFormatElt);
$this->addNumberFormat($numberFormat);
}
foreach ($input['intlNumberFormat'] as $intlNumberFormatElt) {
$numberFormat = new NumberFormat();
$numberFormat->fromArray($intlNumberFormatElt);
$this->addIntlNumberFormat($numberFormat);
}
/*
setMainCountryForCode(objectInput.readBoolean());
*
*/
$this->setMainCountryForCode($input['mainCountryForCode']);
if (isset($input['leadingDigits'])) {
$this->setLeadingDigits($input['leadingDigits']);
}
$this->setLeadingZeroPossible($input['leadingZeroPossible']);
return $this;
}
}