PluginProbe
PayPlug for WooCommerce (Official) / 1.2.6
PayPlug for WooCommerce (Official) v1.2.6
3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 All 101 releases
payplug / lib / libphonenumber / PhoneNumberDesc.php

PhoneNumberDesc.php in PayPlug for WooCommerce (Official) 1.2.6, at lib/libphonenumber/PhoneNumberDesc.php

239 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $hasExampleNumber = false;
13 protected $exampleNumber = '';
14 /**
15 * @var array
16 */
17 protected $possibleLength;
18 /**
19 * @var array
20 */
21 protected $possibleLengthLocalOnly;
22
23 public function __construct()
24 {
25 $this->clear();
26 }
27
28 /**
29 * @return PhoneNumberDesc
30 */
31 public function clear()
32 {
33 $this->clearNationalNumberPattern();
34 $this->clearPossibleLength();
35 $this->clearPossibleLengthLocalOnly();
36 $this->clearExampleNumber();
37
38 return $this;
39 }
40
41 /**
42 * @return array
43 */
44 public function getPossibleLength()
45 {
46 return $this->possibleLength;
47 }
48
49 /**
50 * @param array $possibleLength
51 */
52 public function setPossibleLength($possibleLength)
53 {
54 $this->possibleLength = $possibleLength;
55 }
56
57 public function addPossibleLength($possibleLength)
58 {
59 if (!in_array($possibleLength, $this->possibleLength)) {
60 $this->possibleLength[] = $possibleLength;
61 }
62 }
63
64 public function clearPossibleLength()
65 {
66 $this->possibleLength = array();
67 }
68
69 /**
70 * @return array
71 */
72 public function getPossibleLengthLocalOnly()
73 {
74 return $this->possibleLengthLocalOnly;
75 }
76
77 /**
78 * @param array $possibleLengthLocalOnly
79 */
80 public function setPossibleLengthLocalOnly($possibleLengthLocalOnly)
81 {
82 $this->possibleLengthLocalOnly = $possibleLengthLocalOnly;
83 }
84
85 public function addPossibleLengthLocalOnly($possibleLengthLocalOnly)
86 {
87 if (!in_array($possibleLengthLocalOnly, $this->possibleLengthLocalOnly)) {
88 $this->possibleLengthLocalOnly[] = $possibleLengthLocalOnly;
89 }
90 }
91
92 public function clearPossibleLengthLocalOnly()
93 {
94 $this->possibleLengthLocalOnly = array();
95 }
96
97 /**
98 * @return boolean
99 */
100 public function hasNationalNumberPattern()
101 {
102 return $this->hasNationalNumberPattern;
103 }
104
105 /**
106 * @return string
107 */
108 public function getNationalNumberPattern()
109 {
110 return $this->nationalNumberPattern;
111 }
112
113 /**
114 * @param string $value
115 * @return PhoneNumberDesc
116 */
117 public function setNationalNumberPattern($value)
118 {
119 $this->hasNationalNumberPattern = true;
120 $this->nationalNumberPattern = $value;
121
122 return $this;
123 }
124
125 /**
126 * @return PhoneNumberDesc
127 */
128 public function clearNationalNumberPattern()
129 {
130 $this->hasNationalNumberPattern = false;
131 $this->nationalNumberPattern = '';
132 return $this;
133 }
134
135 /**
136 * @return string
137 */
138 public function hasExampleNumber()
139 {
140 return $this->hasExampleNumber;
141 }
142
143 /**
144 * @return string
145 */
146 public function getExampleNumber()
147 {
148 return $this->exampleNumber;
149 }
150
151 /**
152 * @param string $value
153 * @return PhoneNumberDesc
154 */
155 public function setExampleNumber($value)
156 {
157 $this->hasExampleNumber = true;
158 $this->exampleNumber = $value;
159
160 return $this;
161 }
162
163 /**
164 * @return PhoneNumberDesc
165 */
166 public function clearExampleNumber()
167 {
168 $this->hasExampleNumber = false;
169 $this->exampleNumber = '';
170
171 return $this;
172 }
173
174 /**
175 * @param PhoneNumberDesc $other
176 * @return PhoneNumberDesc
177 */
178 public function mergeFrom(PhoneNumberDesc $other)
179 {
180 if ($other->hasNationalNumberPattern()) {
181 $this->setNationalNumberPattern($other->getNationalNumberPattern());
182 }
183 if ($other->hasExampleNumber()) {
184 $this->setExampleNumber($other->getExampleNumber());
185 }
186 $this->setPossibleLength($other->getPossibleLength());
187 $this->setPossibleLengthLocalOnly($other->getPossibleLengthLocalOnly());
188
189 return $this;
190 }
191
192 /**
193 * @param PhoneNumberDesc $other
194 * @return boolean
195 */
196 public function exactlySameAs(PhoneNumberDesc $other)
197 {
198 return $this->nationalNumberPattern === $other->nationalNumberPattern &&
199 $this->exampleNumber === $other->exampleNumber;
200 }
201
202 /**
203 * @return array
204 */
205 public function toArray()
206 {
207 $data = array();
208 if ($this->hasNationalNumberPattern()) {
209 $data['NationalNumberPattern'] = $this->getNationalNumberPattern();
210 }
211 if ($this->hasExampleNumber()) {
212 $data['ExampleNumber'] = $this->getExampleNumber();
213 }
214
215 $data['PossibleLength'] = $this->getPossibleLength();
216 $data['PossibleLengthLocalOnly'] = $this->getPossibleLengthLocalOnly();
217
218 return $data;
219 }
220
221 /**
222 * @param array $input
223 * @return PhoneNumberDesc
224 */
225 public function fromArray(array $input)
226 {
227 if (isset($input['NationalNumberPattern']) && $input['NationalNumberPattern'] != '') {
228 $this->setNationalNumberPattern($input['NationalNumberPattern']);
229 }
230 if (isset($input['ExampleNumber']) && $input['NationalNumberPattern'] != '') {
231 $this->setExampleNumber($input['ExampleNumber']);
232 }
233 $this->setPossibleLength($input['PossibleLength']);
234 $this->setPossibleLengthLocalOnly($input['PossibleLengthLocalOnly']);
235
236 return $this;
237 }
238 }
239