SecurityController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 65.22 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 30
loc 46
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loginAction() 15 15 1
A checkloginAction() 15 15 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace ClientBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Response;
10
11
/**
12
 * Class SecurityController
13
 */
14
class SecurityController extends Controller
15
{
16
    /**
17
     * @param Request $request
18
     * @Route("/login", name="login")
19
     * @Method({"GET", "POST"})
20
     * @return Response
21
     */
22 View Code Duplication
    public function loginAction(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in 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...
23
    {
24
        $authenticationUtils = $this->get('security.authentication_utils');
25
26
        // get the login error if there is one
27
        $error = $authenticationUtils->getLastAuthenticationError();
28
29
        // last username entered by the user
30
        $lastUsername = $authenticationUtils->getLastUsername();
31
32
        return $this->render('ClientBundle:Security:login.html.twig', array(
33
            'last_username' => $lastUsername,
34
            'error'         => $error,
35
        ));
36
    }
37
38
    /**
39
     * @param Request $request
40
     * @Route("/checklogin", name="checklogin")
41
     * @Method({"GET", "POST"})
42
     * @return Response
43
     */
44 View Code Duplication
    public function checkloginAction(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in 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...
45
    {
46
        $authenticationUtils = $this->get('security.authentication_utils');
47
48
        // get the login error if there is one
49
        $error = $authenticationUtils->getLastAuthenticationError();
50
51
        // last username entered by the user
52
        $lastUsername = $authenticationUtils->getLastUsername();
53
54
        return $this->render('ClientBundle:Security:login.html.twig', [
55
            'last_username' => $lastUsername,
56
            'error'         => $error,
57
        ]);
58
    }
59
}
60