Total Complexity | 7 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
7 | trait HasLayoutKey |
||
8 | { |
||
9 | /** |
||
10 | * The layout's unique identifier. |
||
11 | */ |
||
12 | protected ?string $key = null; |
||
13 | |||
14 | /** |
||
15 | * The layout's temporary identifier. |
||
16 | */ |
||
17 | protected ?string $_key = null; |
||
18 | |||
19 | /** |
||
20 | * Retrieve the group's unique key. |
||
21 | */ |
||
22 | 15 | public function key(): ?string |
|
23 | { |
||
24 | 15 | return $this->key; |
|
25 | } |
||
26 | |||
27 | /** |
||
28 | * Retrieve the key currently in use in the views. |
||
29 | */ |
||
30 | 14 | public function inUseKey(): ?string |
|
31 | { |
||
32 | 14 | return $this->_key ?? $this->key(); |
|
33 | } |
||
34 | |||
35 | /** |
||
36 | * Check if this group matches the given key. |
||
37 | */ |
||
38 | 6 | public function isUseKey(string $groupKey): bool |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Returns an unique key for this group if it's not already the case. |
||
45 | * |
||
46 | * @throws \Exception |
||
47 | */ |
||
48 | 16 | protected function generateValidLayoutKey(string $key): string |
|
63 | } |
||
64 | } |
||
65 |