CalendarMenuModule::title()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2025 webtrees development team
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
 */
17
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\Module;
21
22
use Fisharebest\Webtrees\Http\RequestHandlers\CalendarPage;
23
use Fisharebest\Webtrees\I18N;
0 ignored issues
show
Bug introduced by
The type Fisharebest\Webtrees\I18N was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use Fisharebest\Webtrees\Menu;
25
use Fisharebest\Webtrees\Tree;
26
27
/**
28
 * Class CalendarMenuModule - provide a menu option for the calendar
29
 */
30
class CalendarMenuModule extends AbstractModule implements ModuleMenuInterface
31
{
32
    use ModuleMenuTrait;
33
34
    public function title(): string
35
    {
36
        /* I18N: Name of a module */
37
        return I18N::translate('Calendar');
38
    }
39
40
    public function description(): string
41
    {
42
        /* I18N: Description of the “Calendar” module */
43
        return I18N::translate('The calendar menu.');
44
    }
45
46
    /**
47
     * The default position for this menu.  It can be changed in the control panel.
48
     *
49
     * @return int
50
     */
51
    public function defaultMenuOrder(): int
52
    {
53
        return 4;
54
    }
55
56
    /**
57
     * A menu, to be added to the main application menu.
58
     */
59
    public function getMenu(Tree $tree): Menu|null
60
    {
61
        $submenu = [
62
            $this->calendarDayMenu($tree),
63
            $this->calendarMonthMenu($tree),
64
            $this->calendarYearMenu($tree),
65
        ];
66
67
        return new Menu(I18N::translate('Calendar'), '#', 'menu-calendar', ['rel' => 'nofollow'], $submenu);
68
    }
69
70
    /**
71
     * @param Tree $tree
72
     *
73
     * @return Menu
74
     */
75
    protected function calendarDayMenu(Tree $tree): Menu
76
    {
77
        return new Menu(I18N::translate('Day'), route(CalendarPage::class, [
78
            'view' => 'day',
79
            'tree' => $tree->name(),
80
        ]), 'menu-calendar-day', ['rel' => 'nofollow']);
81
    }
82
83
    /**
84
     * @param Tree $tree
85
     *
86
     * @return Menu
87
     */
88
    protected function calendarMonthMenu(Tree $tree): Menu
89
    {
90
        return new Menu(I18N::translate('Month'), route(CalendarPage::class, [
91
            'view' => 'month',
92
            'tree' => $tree->name(),
93
        ]), 'menu-calendar-month', ['rel' => 'nofollow']);
94
    }
95
96
    /**
97
     * @param Tree $tree
98
     *
99
     * @return Menu
100
     */
101
    protected function calendarYearMenu(Tree $tree): Menu
102
    {
103
        return new Menu(I18N::translate('Year'), route(CalendarPage::class, [
104
            'view' => 'year',
105
            'tree' => $tree->name(),
106
        ]), 'menu-calendar-year', ['rel' => 'nofollow']);
107
    }
108
}
109