Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
42 / 42
100.00% covered (success)
100.00%
14 / 14
40.00% covered (danger)
40.00%
4 / 10
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
AdminController
100.00% covered (success)
100.00%
42 / 42
100.00% covered (success)
100.00%
14 / 14
40.00% covered (danger)
40.00%
4 / 10
100.00% covered (success)
100.00%
3 / 3
26.50
100.00% covered (success)
100.00%
1 / 1
 index
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
6 / 6
0.00% covered (danger)
0.00%
0 / 4
100.00% covered (success)
100.00%
1 / 1
3
 log
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
7 / 7
60.00% covered (warning)
60.00%
3 / 5
100.00% covered (success)
100.00%
1 / 1
6.60
 applicationInfo
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Controller\Admin;
4
5use App\Application;
6use App\Kernel;
7use App\Security\Action;
8use App\Security\Role;
9use App\Service\ApplicationInfo\Output\SymfonyOutput;
10use App\Service\ApplicationInfo\Symfony;
11use Symfony\Component\Finder\Finder;
12use Symfony\Component\HttpFoundation\Request;
13use Symfony\Component\HttpFoundation\Response;
14use Symfony\Component\Routing\Attribute\Route;
15
16#[Route('/admin')]
17class AdminController extends BaseAdminController
18{
19    #[Route('', name: 'admin_page')]
20    public function index(Request $request, Application $application): Response
21    {
22        $this->logger->debug('Debug page');
23        $this->denyAccessUnlessGranted(Action::ADMIN_PAGE);
24        $roles = Role::getRoles();
25        foreach ($roles as $key => $role) {
26            if (!$this->isGranted($role)) {
27                unset($roles[$key]);
28            }
29        }
30
31        return $this->render(
32            'admin/index.html.twig',
33            [
34                'phpVersion' => phpversion(),
35                'symfonyVersion' => \Symfony\Component\HttpKernel\Kernel::VERSION,
36                'httpGinaroles' => $request->server->get('HTTP_GINAROLES', 'pas défini'),
37                'rolesHeritage' => $roles,
38                'user' => $application->getUser(),
39            ]
40        );
41    }
42
43    /**
44     * Display log.
45     */
46    #[Route('/log/{filename}', name: 'admin_log', methods: ['GET'])]
47    public function log(Request $request, Kernel $kernel, ?string $filename = null): Response
48    {
49        $this->logger->info('Debug log');
50        $this->denyAccessUnlessGranted(Action::ADMIN_LOG);
51        $finder = new Finder();
52        $finder->files()->in($kernel->getLogDir());
53        if ($filename) {
54            $filename = preg_replace('/[^_.\\-A-Za-z0-9]+/', '', $filename);
55            if ($filename) {
56                $files = $finder->name($filename);
57                if (0 !== $files->count()) {
58                    $array = iterator_to_array($files);
59                    $file = reset($array);
60                    if ($file) {
61                        $this->logger->info('Debug affichage du log ' . $file->getFilename());
62
63                        return $this->render('admin/log/content.html.twig', ['file' => $file]);
64                    }
65                }
66            }
67            $finder->name('*');
68        }
69        $finder->sortByModifiedTime();
70
71        return $this->render('admin/log/list.html.twig', ['finder' => $finder]);
72    }
73
74    #[Route('/applicationInfo', name: 'applicationInfo')]
75    public function applicationInfo(Request $request): Response
76    {
77        $this->logger->info('applicationInfo');
78        $this->denyAccessUnlessGranted(Action::ADMIN_PAGE);
79
80        $symfonyOutput = new SymfonyOutput();
81        $app = new Symfony($symfonyOutput);
82        unset($app);
83
84        return $this->render(
85            'admin/application_info.html.twig',
86            ['html' => $symfonyOutput->getHtml()]
87        );
88    }
89}

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.

AdminController->applicationInfo
75    public function applicationInfo(Request $request): Response
76    {
77        $this->logger->info('applicationInfo');
78        $this->denyAccessUnlessGranted(Action::ADMIN_PAGE);
79
80        $symfonyOutput = new SymfonyOutput();
81        $app = new Symfony($symfonyOutput);
82        unset($app);
83
84        return $this->render(
85            'admin/application_info.html.twig',
86            ['html' => $symfonyOutput->getHtml()]
87        );
88    }
AdminController->index
20    public function index(Request $request, Application $application): Response
21    {
22        $this->logger->debug('Debug page');
23        $this->denyAccessUnlessGranted(Action::ADMIN_PAGE);
24        $roles = Role::getRoles();
25        foreach ($roles as $key => $role) {
25        foreach ($roles as $key => $role) {
25        foreach ($roles as $key => $role) {
26            if (!$this->isGranted($role)) {
25        foreach ($roles as $key => $role) {
26            if (!$this->isGranted($role)) {
27                unset($roles[$key]);
25        foreach ($roles as $key => $role) {
25        foreach ($roles as $key => $role) {
26            if (!$this->isGranted($role)) {
27                unset($roles[$key]);
28            }
29        }
30
31        return $this->render(
32            'admin/index.html.twig',
33            [
34                'phpVersion' => phpversion(),
35                'symfonyVersion' => \Symfony\Component\HttpKernel\Kernel::VERSION,
36                'httpGinaroles' => $request->server->get('HTTP_GINAROLES', 'pas défini'),
37                'rolesHeritage' => $roles,
38                'user' => $application->getUser(),
39            ]
40        );
41    }
AdminController->log
47    public function log(Request $request, Kernel $kernel, ?string $filename = null): Response
48    {
49        $this->logger->info('Debug log');
50        $this->denyAccessUnlessGranted(Action::ADMIN_LOG);
51        $finder = new Finder();
52        $finder->files()->in($kernel->getLogDir());
53        if ($filename) {
54            $filename = preg_replace('/[^_.\\-A-Za-z0-9]+/', '', $filename);
55            if ($filename) {
56                $files = $finder->name($filename);
57                if (0 !== $files->count()) {
58                    $array = iterator_to_array($files);
59                    $file = reset($array);
60                    if ($file) {
61                        $this->logger->info('Debug affichage du log ' . $file->getFilename());
62
63                        return $this->render('admin/log/content.html.twig', ['file' => $file]);
67            $finder->name('*');
68        }
69        $finder->sortByModifiedTime();
69        $finder->sortByModifiedTime();
70
71        return $this->render('admin/log/list.html.twig', ['finder' => $finder]);
72    }