1 | <?php |
||
11 | class LastnameMapper extends AbstractMapper |
||
12 | { |
||
13 | protected $prefixes = []; |
||
14 | |||
15 | protected $matchSinglePart = false; |
||
16 | |||
17 | public function __construct(array $prefixes, bool $matchSinglePart = false) |
||
22 | |||
23 | /** |
||
24 | * map lastnames in the parts array |
||
25 | * |
||
26 | * @param array $parts the name parts |
||
27 | * @return array the mapped parts |
||
28 | */ |
||
29 | public function map(array $parts): array |
||
41 | |||
42 | /** |
||
43 | * @param array $parts |
||
44 | * @return array |
||
45 | */ |
||
46 | protected function mapReversedParts(array $parts): array |
||
75 | |||
76 | /** |
||
77 | * @param array $parts |
||
78 | * @param int $index |
||
79 | * @return bool |
||
80 | */ |
||
81 | protected function isFollowedByLastnamePart(array $parts, int $index): bool |
||
87 | |||
88 | /** |
||
89 | * Assuming that the part at the given index is matched as a prefix, |
||
90 | * determines if the prefix should be applied to the lastname. |
||
91 | * |
||
92 | * We only apply it to the lastname if we already have at least one |
||
93 | * lastname part and there are other parts left in |
||
94 | * the name (this effectively prioritises firstname over prefix matching). |
||
95 | * |
||
96 | * This expects the parts array and index to be in the original order. |
||
97 | * |
||
98 | * @param array $parts |
||
99 | * @param int $index |
||
100 | * @return bool |
||
101 | */ |
||
102 | protected function isApplicablePrefix(array $parts, int $index): bool |
||
110 | |||
111 | /** |
||
112 | * check if the given word is a lastname prefix |
||
113 | * |
||
114 | * @param string $word the word to check |
||
115 | * @return bool |
||
116 | */ |
||
117 | protected function isPrefix($word): bool |
||
121 | } |
||
122 |