Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| MenuHeader | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| getFallbackText | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | namespace Apie\Core\Translator\ValueObjects; |
| 3 | |
| 4 | use Apie\Core\Attributes\Description; |
| 5 | use Apie\Core\Attributes\ExampleValue; |
| 6 | |
| 7 | #[Description('Menu header translations. Keys reflect the tree structure of the menu')] |
| 8 | #[ExampleValue('apie.menu.header.root.test.authenticated')] |
| 9 | class MenuHeader extends AbstractTranslation |
| 10 | { |
| 11 | protected const MIDDLE_REGEX = '(menu.header|(menu(\.[^.]+(\.[^.]+)*))*\.header)'; |
| 12 | |
| 13 | public function getFallbackText(): string |
| 14 | { |
| 15 | if (preg_match('/\.([^.]+)\.header$/', $this->middleSection, $matches)) { |
| 16 | return $matches[1] ? ucfirst($matches[1]) : 'Home'; |
| 17 | } |
| 18 | return 'Home'; |
| 19 | } |
| 20 | } |