Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
96.97% covered (success)
96.97%
32 / 33
85.71% covered (warning)
85.71%
12 / 14
3.12% covered (danger)
3.12%
2 / 64
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Menu
96.97% covered (success)
96.97%
32 / 33
85.71% covered (warning)
85.71%
12 / 14
3.12% covered (danger)
3.12%
2 / 64
0.00% covered (danger)
0.00%
0 / 1
51.55
0.00% covered (danger)
0.00%
0 / 1
 __construct
96.97% covered (success)
96.97%
32 / 33
85.71% covered (warning)
85.71%
12 / 14
3.12% covered (danger)
3.12%
2 / 64
0.00% covered (danger)
0.00%
0 / 1
51.55
1<?php
2
3namespace App\Menu;
4
5use App\Application;
6use App\Security\Action;
7use App\Security\User;
8use Symfony\Bundle\SecurityBundle\Security;
9
10class Menu extends MenuBase
11{
12    public function __construct(MenuTwig $menuTwig, Security $security, Application $application)
13    {
14        parent::__construct($menuTwig);
15        /** @var ?User $user */
16        $user = $security->getUser();
17
18        $menuTwig->addItem(
19            'redaction_right',
20            new MenuItem(
21                'idConnexion',
22                'Bonjour ' . ($user ? '<strong>' . $user->getUserIdentifier() . '</strong>' : ''),
23                'info'
24            )
25        );
26        if ($user?->hasLogout()) {
27            $menuTwig->addItem('redaction_right', new MenuItem('id_disconnection', 'Se déconnecter', 'saml_logout'));
28        }
29        if ($security->isGranted(Action::NAVBAR_ENVIRONNEMENT)) {
30            $menuTwig->addItem(
31                'redaction_right',
32                new MenuItem(
33                    'environnement',
34                    '<span class="badge rounded-pill ' . $application->getServerType() .
35                    '" data-bs-toggle="tooltip" title="Vous êtes dans l\'environnement de ' .
36                    $application->getServerType() . "\nVersion : " . $application->getVersion() .
37                    '">' . $application->getServerType() . '</span>'
38                )
39            );
40        }
41        $subSettingsMenus = [];
42        if ($security->isGranted(Action::ADMIN_PAGE)) {
43            $subSettingsMenus[] = new MenuItem('admin_page', 'Administration', 'admin_page');
44        }
45        if ($security->isGranted(Action::HOMEPAGE)) {
46            $subSettingsMenus[] = new MenuItem('homepage', 'Accueil', 'homepage');
47        }
48        if ([] !== $subSettingsMenus) {
49            $menuTwig->addItem(
50                'redaction_right',
51                new MenuItem('settings', '<i class="bi bi-gear"></i>', null, [], [], $subSettingsMenus)
52            );
53        }
54    }
55}

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.

Menu->__construct
12    public function __construct(MenuTwig $menuTwig, Security $security, Application $application)
13    {
14        parent::__construct($menuTwig);
15        /** @var ?User $user */
16        $user = $security->getUser();
17
18        $menuTwig->addItem(
19            'redaction_right',
20            new MenuItem(
21                'idConnexion',
22                'Bonjour ' . ($user ? '<strong>' . $user->getUserIdentifier() . '</strong>' : ''),
22                'Bonjour ' . ($user ? '<strong>' . $user->getUserIdentifier() . '</strong>' : ''),
22                'Bonjour ' . ($user ? '<strong>' . $user->getUserIdentifier() . '</strong>' : ''),
22                'Bonjour ' . ($user ? '<strong>' . $user->getUserIdentifier() . '</strong>' : ''),
23                'info'
24            )
25        );
26        if ($user?->hasLogout()) {
27            $menuTwig->addItem('redaction_right', new MenuItem('id_disconnection', 'Se déconnecter', 'saml_logout'));
28        }
29        if ($security->isGranted(Action::NAVBAR_ENVIRONNEMENT)) {
29        if ($security->isGranted(Action::NAVBAR_ENVIRONNEMENT)) {
30            $menuTwig->addItem(
31                'redaction_right',
32                new MenuItem(
33                    'environnement',
34                    '<span class="badge rounded-pill ' . $application->getServerType() .
35                    '" data-bs-toggle="tooltip" title="Vous êtes dans l\'environnement de ' .
36                    $application->getServerType() . "\nVersion : " . $application->getVersion() .
37                    '">' . $application->getServerType() . '</span>'
38                )
39            );
40        }
41        $subSettingsMenus = [];
41        $subSettingsMenus = [];
42        if ($security->isGranted(Action::ADMIN_PAGE)) {
43            $subSettingsMenus[] = new MenuItem('admin_page', 'Administration', 'admin_page');
44        }
45        if ($security->isGranted(Action::HOMEPAGE)) {
45        if ($security->isGranted(Action::HOMEPAGE)) {
46            $subSettingsMenus[] = new MenuItem('homepage', 'Accueil', 'homepage');
47        }
48        if ([] !== $subSettingsMenus) {
48        if ([] !== $subSettingsMenus) {
49            $menuTwig->addItem(
50                'redaction_right',
51                new MenuItem('settings', '<i class="bi bi-gear"></i>', null, [], [], $subSettingsMenus)
52            );
53        }
54    }
54    }