1 | <?php |
||
14 | class Parser |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $whitespace = " \r\n\t"; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $mappers = []; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $languages = []; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $nicknameDelimiters = []; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | protected $maxSalutationIndex = 0; |
||
40 | |||
41 | public function __construct(array $languages = []) |
||
49 | |||
50 | /** |
||
51 | * split full names into the following parts: |
||
52 | * - prefix / salutation (Mr., Mrs., etc) |
||
53 | * - given name / first name |
||
54 | * - middle initials |
||
55 | * - surname / last name |
||
56 | * - suffix (II, Phd, Jr, etc) |
||
57 | * |
||
58 | * @param string $name |
||
59 | * @return Name |
||
60 | */ |
||
61 | public function parse($name): Name |
||
79 | |||
80 | /** |
||
81 | * handles split-parsing of comma-separated name parts |
||
82 | * |
||
83 | * @param $left - the name part left of the comma |
||
84 | * @param $right - the name part right of the comma |
||
85 | * |
||
86 | * @return Name |
||
87 | */ |
||
88 | protected function parseSplitName($first, $second, $third): Name |
||
98 | |||
99 | /** |
||
100 | * @return Parser |
||
101 | */ |
||
102 | protected function getFirstSegmentParser(): Parser |
||
116 | |||
117 | /** |
||
118 | * @return Parser |
||
119 | */ |
||
120 | protected function getSecondSegmentParser(): Parser |
||
135 | |||
136 | protected function getThirdSegmentParser(): Parser |
||
146 | |||
147 | /** |
||
148 | * get the mappers for this parser |
||
149 | * |
||
150 | * @return array |
||
151 | */ |
||
152 | public function getMappers(): array |
||
168 | |||
169 | /** |
||
170 | * set the mappers for this parser |
||
171 | * |
||
172 | * @param array $mappers |
||
173 | * @return Parser |
||
174 | */ |
||
175 | public function setMappers(array $mappers): Parser |
||
181 | |||
182 | /** |
||
183 | * normalize the name |
||
184 | * |
||
185 | * @param string $name |
||
186 | * @return string |
||
187 | */ |
||
188 | protected function normalize(string $name): string |
||
196 | |||
197 | /** |
||
198 | * get a string of characters that are supposed to be treated as whitespace |
||
199 | * |
||
200 | * @return string |
||
201 | */ |
||
202 | public function getWhitespace(): string |
||
206 | |||
207 | /** |
||
208 | * set the string of characters that are supposed to be treated as whitespace |
||
209 | * |
||
210 | * @param $whitespace |
||
211 | * @return Parser |
||
212 | */ |
||
213 | public function setWhitespace($whitespace): Parser |
||
219 | |||
220 | /** |
||
221 | * @return array |
||
222 | */ |
||
223 | protected function getPrefixes() |
||
234 | |||
235 | /** |
||
236 | * @return array |
||
237 | */ |
||
238 | protected function getSuffixes() |
||
249 | |||
250 | /** |
||
251 | * @return array |
||
252 | */ |
||
253 | protected function getSalutations() |
||
264 | |||
265 | /** |
||
266 | * @return array |
||
267 | */ |
||
268 | public function getNicknameDelimiters(): array |
||
272 | |||
273 | /** |
||
274 | * @param array $nicknameDelimiters |
||
275 | * @return Parser |
||
276 | */ |
||
277 | public function setNicknameDelimiters(array $nicknameDelimiters): Parser |
||
283 | |||
284 | /** |
||
285 | * @return int |
||
286 | */ |
||
287 | public function getMaxSalutationIndex(): int |
||
291 | |||
292 | /** |
||
293 | * @param int $maxSalutationIndex |
||
294 | * @return Parser |
||
295 | */ |
||
296 | public function setMaxSalutationIndex(int $maxSalutationIndex): Parser |
||
302 | } |
||
303 |