1 | <?php |
||
8 | class SalutationMapper extends AbstractMapper |
||
9 | { |
||
10 | protected $salutations = []; |
||
11 | |||
12 | protected $maxIndex = 0; |
||
13 | |||
14 | public function __construct(array $salutations, $maxIndex = 0) |
||
19 | |||
20 | /** |
||
21 | * map salutations in the parts array |
||
22 | * |
||
23 | * @param array $parts the name parts |
||
24 | * @return array the mapped parts |
||
25 | */ |
||
26 | public function map(array $parts): array |
||
40 | |||
41 | protected function substituteWithSalutation(array $parts, int $start): array |
||
57 | |||
58 | private function isMatchingSubset(array $keys, array $subset): bool |
||
68 | } |
||
69 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: