1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace libphonenumber; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Phone Number Description |
7
|
|
|
*/ |
8
|
|
|
class PhoneNumberDesc |
9
|
|
|
{ |
10
|
|
|
protected $hasNationalNumberPattern = false; |
11
|
|
|
protected $nationalNumberPattern = ""; |
12
|
|
|
protected $hasPossibleNumberPattern = false; |
13
|
|
|
protected $possibleNumberPattern = ""; |
14
|
|
|
protected $hasExampleNumber = false; |
15
|
|
|
protected $exampleNumber = ""; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @return boolean |
19
|
|
|
*/ |
20
|
|
|
public function hasNationalNumberPattern() |
21
|
|
|
{ |
22
|
|
|
return $this->hasNationalNumberPattern; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @return string |
27
|
|
|
*/ |
28
|
2591 |
|
public function getNationalNumberPattern() |
29
|
|
|
{ |
30
|
2591 |
|
return $this->nationalNumberPattern; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param string $value |
35
|
|
|
* @return PhoneNumberDesc |
36
|
|
|
*/ |
37
|
867 |
|
public function setNationalNumberPattern($value) |
38
|
|
|
{ |
39
|
867 |
|
$this->hasNationalNumberPattern = true; |
40
|
867 |
|
$this->nationalNumberPattern = $value; |
41
|
|
|
|
42
|
867 |
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return boolean |
47
|
|
|
*/ |
48
|
|
|
public function hasPossibleNumberPattern() |
49
|
|
|
{ |
50
|
|
|
return $this->hasPossibleNumberPattern; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return string |
55
|
|
|
*/ |
56
|
2768 |
|
public function getPossibleNumberPattern() |
57
|
|
|
{ |
58
|
2768 |
|
return $this->possibleNumberPattern; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param string $value |
63
|
|
|
* @return PhoneNumberDesc |
64
|
|
|
*/ |
65
|
866 |
|
public function setPossibleNumberPattern($value) |
66
|
|
|
{ |
67
|
866 |
|
$this->hasPossibleNumberPattern = true; |
68
|
866 |
|
$this->possibleNumberPattern = $value; |
69
|
|
|
|
70
|
866 |
|
return $this; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
4864 |
|
public function hasExampleNumber() |
77
|
|
|
{ |
78
|
4864 |
|
return $this->hasExampleNumber; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
2666 |
|
public function getExampleNumber() |
85
|
|
|
{ |
86
|
2666 |
|
return $this->exampleNumber; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param string $value |
91
|
|
|
* @return PhoneNumberDesc |
92
|
|
|
*/ |
93
|
848 |
|
public function setExampleNumber($value) |
94
|
|
|
{ |
95
|
848 |
|
$this->hasExampleNumber = true; |
96
|
848 |
|
$this->exampleNumber = $value; |
97
|
|
|
|
98
|
848 |
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @param PhoneNumberDesc $other |
103
|
|
|
* @return PhoneNumberDesc |
104
|
|
|
*/ |
105
|
|
|
public function mergeFrom(PhoneNumberDesc $other) |
106
|
|
|
{ |
107
|
|
|
if ($other->hasNationalNumberPattern()) { |
108
|
|
|
$this->setNationalNumberPattern($other->getNationalNumberPattern()); |
109
|
|
|
} |
110
|
|
|
if ($other->hasPossibleNumberPattern()) { |
111
|
|
|
$this->setPossibleNumberPattern($other->getPossibleNumberPattern()); |
112
|
|
|
} |
113
|
|
|
if ($other->hasExampleNumber()) { |
114
|
|
|
$this->setExampleNumber($other->getExampleNumber()); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param PhoneNumberDesc $other |
122
|
|
|
* @return boolean |
123
|
|
|
*/ |
124
|
1 |
|
public function exactlySameAs(PhoneNumberDesc $other) |
125
|
|
|
{ |
126
|
1 |
|
return $this->nationalNumberPattern === $other->nationalNumberPattern && |
127
|
1 |
|
$this->possibleNumberPattern === $other->possibleNumberPattern && |
128
|
1 |
|
$this->exampleNumber === $other->exampleNumber; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return array |
133
|
|
|
*/ |
134
|
|
|
public function toArray() |
135
|
|
|
{ |
136
|
|
|
$data = array(); |
137
|
|
|
if ($this->hasNationalNumberPattern()) { |
138
|
|
|
$data['NationalNumberPattern'] = $this->getNationalNumberPattern(); |
139
|
|
|
} |
140
|
|
|
if ($this->hasPossibleNumberPattern()) { |
141
|
|
|
$data['PossibleNumberPattern'] = $this->getPossibleNumberPattern(); |
142
|
|
|
} |
143
|
|
|
if ($this->hasExampleNumber()) { |
144
|
|
|
$data['ExampleNumber'] = $this->getExampleNumber(); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
return $data; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @param array $input |
152
|
|
|
* @return PhoneNumberDesc |
153
|
|
|
*/ |
154
|
866 |
|
public function fromArray(array $input) |
155
|
|
|
{ |
156
|
866 |
|
if (isset($input['NationalNumberPattern']) && $input['NationalNumberPattern'] != '') { |
157
|
866 |
|
$this->setNationalNumberPattern($input['NationalNumberPattern']); |
158
|
|
|
} |
159
|
866 |
|
if (isset($input['PossibleNumberPattern']) && $input['NationalNumberPattern'] != '') { |
160
|
866 |
|
$this->setPossibleNumberPattern($input['PossibleNumberPattern']); |
161
|
|
|
} |
162
|
866 |
|
if (isset($input['ExampleNumber']) && $input['NationalNumberPattern'] != '') { |
163
|
848 |
|
$this->setExampleNumber($input['ExampleNumber']); |
164
|
|
|
} |
165
|
|
|
|
166
|
866 |
|
return $this; |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|