Total Complexity | 5 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | abstract class GroupedTemplate extends ATemplate |
||
12 | { |
||
13 | /** @var array<string, string> */ |
||
14 | protected static array $knownTemplates; |
||
15 | |||
16 | 2 | protected function loadTemplate(): string |
|
17 | { |
||
18 | 2 | if (empty(static::$knownTemplates)) { |
|
19 | 1 | static::$knownTemplates = $this->defineAvailableTemplates(); |
|
20 | } |
||
21 | 2 | return ''; |
|
22 | } |
||
23 | |||
24 | /** |
||
25 | * Define templates available from this class |
||
26 | * array key is to select one, value is for content |
||
27 | * @return array<string, string> |
||
28 | */ |
||
29 | abstract protected function defineAvailableTemplates(): array; |
||
30 | |||
31 | 2 | protected function resetItems(): self |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param string $key |
||
39 | * @throws TemplateException |
||
40 | * @return $this |
||
41 | * Call only from method in extending class and be prepared for resetting items due unavailability some of them |
||
42 | */ |
||
43 | 2 | protected function selectTemplate(string $key): self |
|
50 | } |
||
51 | } |
||
52 |