Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
20 / 20 |
|
100.00% |
10 / 10 |
|
50.00% |
4 / 8 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| DefaultController | |
100.00% |
20 / 20 |
|
100.00% |
10 / 10 |
|
50.00% |
4 / 8 |
|
100.00% |
5 / 5 |
13.12 | |
100.00% |
1 / 1 |
| index | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| info | |
100.00% |
8 / 8 |
|
100.00% |
6 / 6 |
|
0.00% |
0 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| todo | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| editor | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| e500 | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Controller; |
| 4 | |
| 5 | use App\ExceptionApplication; |
| 6 | use App\Parameter; |
| 7 | use App\Security\Action; |
| 8 | use App\Security\Role; |
| 9 | use Symfony\Component\HttpFoundation\Response; |
| 10 | use Symfony\Component\Routing\Attribute\Route; |
| 11 | |
| 12 | class DefaultController extends BaseFrontController |
| 13 | { |
| 14 | #[Route('/', name: 'homepage')] |
| 15 | public function index(Parameter $parameter): Response |
| 16 | { |
| 17 | $this->denyAccessUnlessGranted(Action::HOMEPAGE); |
| 18 | $this->logDebug('Home page'); |
| 19 | |
| 20 | return $this->render( |
| 21 | 'home.html.twig' |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | #[Route('/info', name: 'info')] |
| 26 | public function info(Parameter $parameter): Response |
| 27 | { |
| 28 | $this->denyAccessUnlessGranted(Action::HOMEPAGE); |
| 29 | $roles = Role::getRoles(); |
| 30 | foreach ($roles as $key => $role) { |
| 31 | if (!$this->isGranted($role)) { |
| 32 | unset($roles[$key]); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return $this->render( |
| 37 | 'info.html.twig', |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | #[Route('/todo', name: 'todo')] |
| 42 | public function todo(): Response |
| 43 | { |
| 44 | $this->logWarning('page todo'); |
| 45 | |
| 46 | return $this->render('todo.html.twig'); |
| 47 | } |
| 48 | |
| 49 | #[Route('/editor', name: 'editor')] |
| 50 | public function editor(): Response |
| 51 | { |
| 52 | $this->denyAccessUnlessGranted(Role::ALL); |
| 53 | $this->logInfo('Page editor'); |
| 54 | |
| 55 | return $this->render('editor.html.twig'); |
| 56 | } |
| 57 | |
| 58 | /* |
| 59 | * Error simulation |
| 60 | * |
| 61 | * @throws ExceptionApplication |
| 62 | */ |
| 63 | #[Route('/500', name: '500')] |
| 64 | public function e500(): Response |
| 65 | { |
| 66 | $this->logError('Erreur 500'); |
| 67 | throw new ExceptionApplication('error'); |
| 68 | } |
| 69 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 66 | $this->logError('Erreur 500'); |
| 67 | throw new ExceptionApplication('error'); |
| 68 | } |
| 52 | $this->denyAccessUnlessGranted(Role::ALL); |
| 53 | $this->logInfo('Page editor'); |
| 54 | |
| 55 | return $this->render('editor.html.twig'); |
| 56 | } |
| 15 | public function index(Parameter $parameter): Response |
| 16 | { |
| 17 | $this->denyAccessUnlessGranted(Action::HOMEPAGE); |
| 18 | $this->logDebug('Home page'); |
| 19 | |
| 20 | return $this->render( |
| 21 | 'home.html.twig' |
| 22 | ); |
| 23 | } |
| 26 | public function info(Parameter $parameter): Response |
| 27 | { |
| 28 | $this->denyAccessUnlessGranted(Action::HOMEPAGE); |
| 29 | $roles = Role::getRoles(); |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 31 | if (!$this->isGranted($role)) { |
| 30 | foreach ($roles as $key => $role) { |
| 31 | if (!$this->isGranted($role)) { |
| 32 | unset($roles[$key]); |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 31 | if (!$this->isGranted($role)) { |
| 32 | unset($roles[$key]); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return $this->render( |
| 37 | 'info.html.twig', |
| 38 | ); |
| 39 | } |
| 26 | public function info(Parameter $parameter): Response |
| 27 | { |
| 28 | $this->denyAccessUnlessGranted(Action::HOMEPAGE); |
| 29 | $roles = Role::getRoles(); |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 31 | if (!$this->isGranted($role)) { |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 31 | if (!$this->isGranted($role)) { |
| 32 | unset($roles[$key]); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return $this->render( |
| 37 | 'info.html.twig', |
| 38 | ); |
| 39 | } |
| 26 | public function info(Parameter $parameter): Response |
| 27 | { |
| 28 | $this->denyAccessUnlessGranted(Action::HOMEPAGE); |
| 29 | $roles = Role::getRoles(); |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 31 | if (!$this->isGranted($role)) { |
| 32 | unset($roles[$key]); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return $this->render( |
| 37 | 'info.html.twig', |
| 38 | ); |
| 39 | } |
| 26 | public function info(Parameter $parameter): Response |
| 27 | { |
| 28 | $this->denyAccessUnlessGranted(Action::HOMEPAGE); |
| 29 | $roles = Role::getRoles(); |
| 30 | foreach ($roles as $key => $role) { |
| 30 | foreach ($roles as $key => $role) { |
| 31 | if (!$this->isGranted($role)) { |
| 32 | unset($roles[$key]); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return $this->render( |
| 37 | 'info.html.twig', |
| 38 | ); |
| 39 | } |
| 44 | $this->logWarning('page todo'); |
| 45 | |
| 46 | return $this->render('todo.html.twig'); |
| 47 | } |