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 |
||
58 | |||
59 | /** |
||
60 | * handles split-parsing of comma-separated name parts |
||
61 | * |
||
62 | * @param $left - the name part left of the comma |
||
63 | * @param $right - the name part right of the comma |
||
64 | * |
||
65 | * @return Name |
||
66 | */ |
||
67 | protected function parseSplitName($first, $second, $third): Name |
||
77 | |||
78 | /** |
||
79 | * @return Parser |
||
80 | */ |
||
81 | protected function getFirstSegmentParser(): Parser |
||
94 | |||
95 | /** |
||
96 | * @return Parser |
||
97 | */ |
||
98 | protected function getSecondSegmentParser(): Parser |
||
112 | |||
113 | protected function getThirdSegmentParser(): Parser |
||
122 | |||
123 | /** |
||
124 | * get the mappers for this parser |
||
125 | * |
||
126 | * @return array |
||
127 | */ |
||
128 | public function getMappers(): array |
||
144 | |||
145 | /** |
||
146 | * set the mappers for this parser |
||
147 | * |
||
148 | * @param array $mappers |
||
149 | * @return Parser |
||
150 | */ |
||
151 | public function setMappers(array $mappers): Parser |
||
157 | |||
158 | /** |
||
159 | * normalize the name |
||
160 | * |
||
161 | * @param string $name |
||
162 | * @return string |
||
163 | */ |
||
164 | protected function normalize(string $name): string |
||
172 | |||
173 | /** |
||
174 | * get a string of characters that are supposed to be treated as whitespace |
||
175 | * |
||
176 | * @return string |
||
177 | */ |
||
178 | public function getWhitespace(): string |
||
182 | |||
183 | /** |
||
184 | * set the string of characters that are supposed to be treated as whitespace |
||
185 | * |
||
186 | * @param $whitespace |
||
187 | * @return Parser |
||
188 | */ |
||
189 | public function setWhitespace($whitespace): Parser |
||
195 | } |
||
196 |
This check looks for the bodies of
if
statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
if
bodies can be removed. If you have an empty if but statements in theelse
branch, consider inverting the condition.could be turned into
This is much more concise to read.