1 | <?php |
||
8 | abstract class AbstractMapper |
||
9 | { |
||
10 | /** |
||
11 | * implements the mapping of parts |
||
12 | * |
||
13 | * @param array $parts - the name parts |
||
14 | * @return array $parts - the mapped parts |
||
15 | */ |
||
16 | abstract public function map(array $parts); |
||
17 | |||
18 | /** |
||
19 | * checks if there are still unmapped parts left before the given position |
||
20 | * |
||
21 | * @param array $parts |
||
22 | * @param $index |
||
23 | * @return bool |
||
24 | */ |
||
25 | protected function hasUnmappedPartsBefore(array $parts, $index): bool |
||
39 | |||
40 | /** |
||
41 | * @param string $type |
||
42 | * @param array $parts |
||
43 | * @return int|bool |
||
44 | */ |
||
45 | protected function findFirstMapped(string $type, array $parts) |
||
46 | { |
||
47 | $total = count($parts); |
||
48 | |||
49 | for ($i = 0; $i < $total; $i++) { |
||
50 | if ($parts[$i] instanceof $type) { |
||
51 | return $i; |
||
52 | } |
||
53 | } |
||
54 | |||
55 | return false; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * get the registry lookup key for the given word |
||
60 | * |
||
61 | * @param string $word the word |
||
62 | * @return string the key |
||
63 | */ |
||
64 | protected function getKey($word): string |
||
68 | } |
||
69 |