Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
68 / 68
96.15% covered (success)
96.15%
25 / 26
0.02% covered (danger)
0.02%
1 / 4096
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
MenuAdmin
100.00% covered (success)
100.00%
68 / 68
96.15% covered (success)
96.15%
25 / 26
0.02% covered (danger)
0.02%
1 / 4096
100.00% covered (success)
100.00%
1 / 1
181.88
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
68 / 68
96.15% covered (success)
96.15%
25 / 26
0.02% covered (danger)
0.02%
1 / 4096
100.00% covered (success)
100.00%
1 / 1
181.88
1<?php
2
3namespace App\Menu;
4
5use App\Application;
6use App\Security\Action;
7use Symfony\Bundle\SecurityBundle\Security;
8
9class MenuAdmin extends MenuBase
10{
11    public function __construct(MenuTwig $menuTwig, Security $security, Application $application)
12    {
13        parent::__construct($menuTwig);
14        $user = $security->getUser();
15        if ($security->isGranted(Action::ADMIN_PAGE)) {
16            $menuTwig->addItem(
17                'redaction_left',
18                new MenuItem('admin_page', 'Information', 'admin_page')
19            );
20        }
21        if ($security->isGranted(Action::ADMIN_PARAMETER)) {
22            $menuTwig->addItem(
23                'redaction_left',
24                new MenuItem('admin_parameter', 'Parameter', 'admin_parameter')
25            );
26        }
27        if ($security->isGranted(Action::ADMIN_MAIL_TEST)) {
28            $menuTwig->addItem(
29                'redaction_left',
30                new MenuItem('admin_mail_test', 'Test Email', 'admin_mail_test')
31            );
32        }
33
34        if ($security->isGranted(Action::ADMIN_PAGE)) {
35            $menuTwig->addItem('redaction_left', new MenuItem('Edit Page', 'editor', 'editor'));
36        }
37        if ($security->isGranted(Action::ADMIN_PAGE)) {
38            $menuTwig->addItem('redaction_left', new MenuItem('todo', 'To Do', 'todo'));
39        }
40
41        $menuTwig->addItem(
42            'redaction_left',
43            new MenuItem('applicationInfo', 'applicationInfo', 'applicationInfo')
44        );
45        if ($security->isGranted(Action::ADMIN_LOG)) {
46            $menuTwig->addItem('redaction_left', new MenuItem('admin_log', 'logs', 'admin_log'));
47        }
48        $subDemoMenus = [
49            new MenuItem('demo1', 'Demo', 'homepage'),
50            new MenuItem('demo2', 'ge.ch', null, null, ['url' => 'https://ge.ch']),
51            new MenuItem('demo3', 'SITG', null, null, ['url' => 'https://sitg.ge.ch']),
52        ];
53        if ($security->isGranted(Action::ADMIN_PAGE)) {
54            $menuTwig->addItem(
55                'redaction_left',
56                new MenuItem('admin_demo', 'Démo', null, [], [], $subDemoMenus)
57            );
58        }
59        $menuTwig->addItem(
60            'redaction_right',
61            new MenuItem(
62                'idConnexion',
63                'Bonjour ' . ($user instanceof \Symfony\Component\Security\Core\User\UserInterface ? '<strong>' .
64                    $user->getUserIdentifier() . '</strong>' : ''),
65                'info'
66            )
67        );
68        $menuTwig->addItem('redaction_right', new MenuItem('idDeconnexion', 'Se déconnecter', 'saml_logout'));
69        if ($security->isGranted(Action::NAVBAR_ENVIRONNEMENT)) {
70            $menuTwig->addItem(
71                'redaction_right',
72                new MenuItem(
73                    'environnement',
74                    '<span class="badge rounded-pill ' . $application->getServerType() .
75                    '" data-bs-toggle="tooltip" title="Vous êtes dans l\'environnement de ' .
76                    $application->getServerType() . "\nVersion : " . $application->getVersion() . '">' .
77                    $application->getServerType() . '</span>'
78                )
79            );
80        }
81        $subSettingsMenus = [];
82        if ($security->isGranted(Action::ADMIN_PAGE)) {
83            $subSettingsMenus[] = new MenuItem('admin_page', 'Administration', 'admin_page');
84        }
85        if ($security->isGranted(Action::HOMEPAGE)) {
86            $subSettingsMenus[] = new MenuItem('homepage', 'Accueil', 'homepage');
87        }
88        if ([] !== $subSettingsMenus) {
89            $menuTwig->addItem(
90                'redaction_right',
91                new MenuItem('settings', '<i class="bi bi-gear"></i>', null, [], [], $subSettingsMenus)
92            );
93        }
94    }
95}

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

MenuAdmin->__construct
11    public function __construct(MenuTwig $menuTwig, Security $security, Application $application)
12    {
13        parent::__construct($menuTwig);
14        $user = $security->getUser();
15        if ($security->isGranted(Action::ADMIN_PAGE)) {
16            $menuTwig->addItem(
17                'redaction_left',
18                new MenuItem('admin_page', 'Information', 'admin_page')
19            );
20        }
21        if ($security->isGranted(Action::ADMIN_PARAMETER)) {
21        if ($security->isGranted(Action::ADMIN_PARAMETER)) {
22            $menuTwig->addItem(
23                'redaction_left',
24                new MenuItem('admin_parameter', 'Parameter', 'admin_parameter')
25            );
26        }
27        if ($security->isGranted(Action::ADMIN_MAIL_TEST)) {
27        if ($security->isGranted(Action::ADMIN_MAIL_TEST)) {
28            $menuTwig->addItem(
29                'redaction_left',
30                new MenuItem('admin_mail_test', 'Test Email', 'admin_mail_test')
31            );
32        }
33
34        if ($security->isGranted(Action::ADMIN_PAGE)) {
34        if ($security->isGranted(Action::ADMIN_PAGE)) {
35            $menuTwig->addItem('redaction_left', new MenuItem('Edit Page', 'editor', 'editor'));
36        }
37        if ($security->isGranted(Action::ADMIN_PAGE)) {
37        if ($security->isGranted(Action::ADMIN_PAGE)) {
38            $menuTwig->addItem('redaction_left', new MenuItem('todo', 'To Do', 'todo'));
39        }
40
41        $menuTwig->addItem(
41        $menuTwig->addItem(
42            'redaction_left',
43            new MenuItem('applicationInfo', 'applicationInfo', 'applicationInfo')
44        );
45        if ($security->isGranted(Action::ADMIN_LOG)) {
46            $menuTwig->addItem('redaction_left', new MenuItem('admin_log', 'logs', 'admin_log'));
47        }
48        $subDemoMenus = [
49            new MenuItem('demo1', 'Demo', 'homepage'),
49            new MenuItem('demo1', 'Demo', 'homepage'),
50            new MenuItem('demo2', 'ge.ch', null, null, ['url' => 'https://ge.ch']),
51            new MenuItem('demo3', 'SITG', null, null, ['url' => 'https://sitg.ge.ch']),
52        ];
53        if ($security->isGranted(Action::ADMIN_PAGE)) {
54            $menuTwig->addItem(
55                'redaction_left',
56                new MenuItem('admin_demo', 'Démo', null, [], [], $subDemoMenus)
57            );
58        }
59        $menuTwig->addItem(
59        $menuTwig->addItem(
60            'redaction_right',
61            new MenuItem(
62                'idConnexion',
63                'Bonjour ' . ($user instanceof \Symfony\Component\Security\Core\User\UserInterface ? '<strong>' .
64                    $user->getUserIdentifier() . '</strong>' : ''),
64                    $user->getUserIdentifier() . '</strong>' : ''),
64                    $user->getUserIdentifier() . '</strong>' : ''),
65                'info'
66            )
67        );
68        $menuTwig->addItem('redaction_right', new MenuItem('idDeconnexion', 'Se déconnecter', 'saml_logout'));
69        if ($security->isGranted(Action::NAVBAR_ENVIRONNEMENT)) {
70            $menuTwig->addItem(
71                'redaction_right',
72                new MenuItem(
73                    'environnement',
74                    '<span class="badge rounded-pill ' . $application->getServerType() .
75                    '" data-bs-toggle="tooltip" title="Vous êtes dans l\'environnement de ' .
76                    $application->getServerType() . "\nVersion : " . $application->getVersion() . '">' .
77                    $application->getServerType() . '</span>'
78                )
79            );
80        }
81        $subSettingsMenus = [];
81        $subSettingsMenus = [];
82        if ($security->isGranted(Action::ADMIN_PAGE)) {
83            $subSettingsMenus[] = new MenuItem('admin_page', 'Administration', 'admin_page');
84        }
85        if ($security->isGranted(Action::HOMEPAGE)) {
85        if ($security->isGranted(Action::HOMEPAGE)) {
86            $subSettingsMenus[] = new MenuItem('homepage', 'Accueil', 'homepage');
87        }
88        if ([] !== $subSettingsMenus) {
88        if ([] !== $subSettingsMenus) {
89            $menuTwig->addItem(
90                'redaction_right',
91                new MenuItem('settings', '<i class="bi bi-gear"></i>', null, [], [], $subSettingsMenus)
92            );
93        }
94    }
94    }