DefaultController::loggedoutAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Controller;
4
5
use Dontdrinkandroot\GitkiBundle\Controller\BaseController;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\Security\Core\Exception\AuthenticationException;
9
10
class DefaultController extends BaseController
11
{
12
    public function indexAction()
13
    {
14
        return $this->redirect($this->generateUrl('ddr_gitki_directory', ['path' => '/', 'action' => 'index']));
15
    }
16
17
    public function loginAction(Request $request)
18
    {
19 View Code Duplication
        if (!$this->isGranted('ROLE_USER')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
21
            /* Save targetpath if user was not logged in yet before redirecting to login page */
22
            if ($request->hasSession() && $request->isMethodSafe(false)) {
0 ignored issues
show
Unused Code introduced by
The call to Request::isMethodSafe() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
23
                $referer = $request->headers->get('referer');
24
                if (null !== $referer) {
25
                    $request->getSession()->set('ddr.gitki.manuallogin.targetpath', $referer);
26
                }
27
            }
28
29
            throw new AuthenticationException();
30
        }
31
32 View Code Duplication
        if ($request->hasSession() && $request->isMethodSafe(false)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Unused Code introduced by
The call to Request::isMethodSafe() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
33
34
            /* Restore target path after login */
35
            $targetPath = $request->getSession()->get('ddr.gitki.manuallogin.targetpath');
36
            $request->getSession()->remove('ddr.gitki.manuallogin.targetpath');
37
            if (null !== $targetPath) {
38
                return $this->redirect($targetPath);
39
            }
40
        }
41
42
        return $this->redirect($this->generateUrl('ddr_gitki_directory', ['path' => '/', 'action' => 'index']));
43
    }
44
45
    /**
46
     * @return Response
47
     */
48
    public function loggedoutAction()
49
    {
50
        return $this->render('Default/loggedout.html.twig');
51
    }
52
}
53