1 | <?php |
||
11 | class InitialMapper extends AbstractMapper |
||
12 | { |
||
13 | protected $matchLastPart = false; |
||
14 | |||
15 | private $combinedMax = 2; |
||
16 | |||
17 | public function __construct(int $combinedMax = 2, bool $matchLastPart = false) |
||
22 | |||
23 | /** |
||
24 | * map intials in parts array |
||
25 | * |
||
26 | * @param array $parts the name parts |
||
27 | * @return array the mapped parts |
||
28 | */ |
||
29 | public function map(array $parts): array |
||
62 | |||
63 | /** |
||
64 | * @param string $part |
||
65 | * @return bool |
||
66 | */ |
||
67 | protected function isInitial(string $part): bool |
||
77 | } |
||
78 |
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: