1 | <?php |
||
13 | class Parser |
||
14 | { |
||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $whitespace = " \r\n\t"; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $mappers = []; |
||
24 | |||
25 | /** |
||
26 | * split full names into the following parts: |
||
27 | * - prefix / salutation (Mr., Mrs., etc) |
||
28 | * - given name / first name |
||
29 | * - middle initials |
||
30 | * - surname / last name |
||
31 | * - suffix (II, Phd, Jr, etc) |
||
32 | * |
||
33 | * @param string $name |
||
34 | * @return Name |
||
35 | */ |
||
36 | public function parse($name): Name |
||
54 | |||
55 | /** |
||
56 | * handles split-parsing of comma-separated name parts |
||
57 | * |
||
58 | * @param $left - the name part left of the comma |
||
59 | * @param $right - the name part right of the comma |
||
60 | * |
||
61 | * @return Name |
||
62 | */ |
||
63 | protected function parseSplitName($first, $second, $third): Name |
||
73 | |||
74 | /** |
||
75 | * @return Parser |
||
76 | */ |
||
77 | protected function getFirstSegmentParser(): Parser |
||
90 | |||
91 | /** |
||
92 | * @return Parser |
||
93 | */ |
||
94 | protected function getSecondSegmentParser(): Parser |
||
108 | |||
109 | protected function getThirdSegmentParser(): Parser |
||
118 | |||
119 | /** |
||
120 | * get the mappers for this parser |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | public function getMappers(): array |
||
140 | |||
141 | /** |
||
142 | * set the mappers for this parser |
||
143 | * |
||
144 | * @param array $mappers |
||
145 | * @return Parser |
||
146 | */ |
||
147 | public function setMappers(array $mappers): Parser |
||
153 | |||
154 | /** |
||
155 | * normalize the name |
||
156 | * |
||
157 | * @param string $name |
||
158 | * @return string |
||
159 | */ |
||
160 | protected function normalize(string $name): string |
||
168 | |||
169 | /** |
||
170 | * get a string of characters that are supposed to be treated as whitespace |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | public function getWhitespace(): string |
||
178 | |||
179 | /** |
||
180 | * set the string of characters that are supposed to be treated as whitespace |
||
181 | * |
||
182 | * @param $whitespace |
||
183 | * @return Parser |
||
184 | */ |
||
185 | public function setWhitespace($whitespace): Parser |
||
191 | } |
||
192 |