1 | <?php |
||
8 | class NumberFormat |
||
9 | { |
||
10 | protected $pattern = null; |
||
11 | protected $format = null; |
||
12 | protected $leadingDigitsPattern = array(); |
||
13 | protected $nationalPrefixFormattingRule = null; |
||
14 | /** |
||
15 | * @var bool |
||
16 | */ |
||
17 | protected $nationalPrefixOptionalWhenFormatting = false; |
||
18 | protected $domesticCarrierCodeFormattingRule = null; |
||
19 | |||
20 | 772 | public function __construct() |
|
21 | { |
||
22 | 772 | $this->clear(); |
|
23 | 772 | } |
|
24 | |||
25 | /** |
||
26 | * @return NumberFormat |
||
27 | */ |
||
28 | 772 | public function clear() |
|
39 | |||
40 | /** |
||
41 | * @return boolean |
||
42 | */ |
||
43 | 13 | public function hasPattern() |
|
47 | |||
48 | /** |
||
49 | * @return string |
||
50 | */ |
||
51 | 254 | public function getPattern() |
|
55 | |||
56 | /** |
||
57 | * @param string $value |
||
58 | * @return NumberFormat |
||
59 | */ |
||
60 | 770 | public function setPattern($value) |
|
66 | |||
67 | /** |
||
68 | * @return boolean |
||
69 | */ |
||
70 | 211 | public function isNationalPrefixOptionalWhenFormatting() |
|
74 | |||
75 | /** |
||
76 | * @param boolean $nationalPrefixOptionalWhenFormatting |
||
77 | */ |
||
78 | 764 | public function setNationalPrefixOptionalWhenFormatting($nationalPrefixOptionalWhenFormatting) |
|
82 | |||
83 | /** |
||
84 | * @return boolean |
||
85 | */ |
||
86 | 16 | public function hasFormat() |
|
90 | |||
91 | /** |
||
92 | * @return string |
||
93 | */ |
||
94 | 257 | public function getFormat() |
|
98 | |||
99 | /** |
||
100 | * @param string $value |
||
101 | * @return NumberFormat |
||
102 | */ |
||
103 | 768 | public function setFormat($value) |
|
109 | |||
110 | /** |
||
111 | * @return string |
||
112 | */ |
||
113 | 199 | public function leadingDigitPatterns() |
|
114 | { |
||
115 | 199 | return $this->leadingDigitsPattern; |
|
116 | } |
||
117 | |||
118 | /** |
||
119 | * @return int |
||
120 | */ |
||
121 | 54 | public function leadingDigitsPatternSize() |
|
122 | { |
||
123 | 54 | return count($this->leadingDigitsPattern); |
|
124 | } |
||
125 | |||
126 | /** |
||
127 | * @param int $index |
||
128 | * @return string |
||
129 | */ |
||
130 | 43 | public function getLeadingDigitsPattern($index) |
|
134 | |||
135 | /** |
||
136 | * @param string $value |
||
137 | * @return NumberFormat |
||
138 | */ |
||
139 | 560 | public function addLeadingDigitsPattern($value) |
|
145 | |||
146 | /** |
||
147 | * @return boolean |
||
148 | */ |
||
149 | 211 | public function hasNationalPrefixFormattingRule() |
|
153 | |||
154 | /** |
||
155 | * @return string |
||
156 | */ |
||
157 | 250 | public function getNationalPrefixFormattingRule() |
|
161 | |||
162 | /** |
||
163 | * @param string $value |
||
164 | * @return NumberFormat |
||
165 | */ |
||
166 | 764 | public function setNationalPrefixFormattingRule($value) |
|
172 | |||
173 | /** |
||
174 | * @return NumberFormat |
||
175 | */ |
||
176 | 2 | public function clearNationalPrefixFormattingRule() |
|
177 | { |
||
178 | 2 | $this->nationalPrefixFormattingRule = null; |
|
179 | |||
180 | 2 | return $this; |
|
181 | } |
||
182 | |||
183 | /** |
||
184 | * @return boolean |
||
185 | */ |
||
186 | 211 | public function hasDomesticCarrierCodeFormattingRule() |
|
190 | |||
191 | /** |
||
192 | * @return string |
||
193 | */ |
||
194 | 213 | public function getDomesticCarrierCodeFormattingRule() |
|
198 | |||
199 | /** |
||
200 | * @param string $value |
||
201 | * @return NumberFormat |
||
202 | */ |
||
203 | 764 | public function setDomesticCarrierCodeFormattingRule($value) |
|
209 | |||
210 | /** |
||
211 | * @param NumberFormat $other |
||
212 | * @return NumberFormat |
||
213 | */ |
||
214 | 13 | public function mergeFrom(NumberFormat $other) |
|
236 | |||
237 | /** |
||
238 | * @return array |
||
239 | */ |
||
240 | 198 | public function toArray() |
|
241 | { |
||
242 | 198 | $output = array(); |
|
243 | 198 | $output['pattern'] = $this->getPattern(); |
|
244 | 198 | $output['format'] = $this->getFormat(); |
|
245 | |||
246 | 198 | $output['leadingDigitsPatterns'] = $this->leadingDigitPatterns(); |
|
247 | |||
248 | 198 | if ($this->hasNationalPrefixFormattingRule()) { |
|
249 | 198 | $output['nationalPrefixFormattingRule'] = $this->getNationalPrefixFormattingRule(); |
|
250 | 198 | } |
|
251 | |||
252 | 198 | if ($this->hasDomesticCarrierCodeFormattingRule()) { |
|
253 | 198 | $output['domesticCarrierCodeFormattingRule'] = $this->getDomesticCarrierCodeFormattingRule(); |
|
254 | 198 | } |
|
255 | |||
256 | 198 | $output['nationalPrefixOptionalWhenFormatting'] = $this->isNationalPrefixOptionalWhenFormatting(); |
|
257 | |||
258 | 198 | return $output; |
|
259 | } |
||
260 | |||
261 | /** |
||
262 | * @param array $input |
||
263 | */ |
||
264 | 754 | public function fromArray(array $input) |
|
281 | } |
||
282 |