Completed
Pull Request — master (#33)
by Pavel
03:21
created

AdminInfoUsersController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 21.43 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 72.72%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 3
c 2
b 0
f 2
lcom 0
cbo 5
dl 6
loc 28
ccs 8
cts 11
cp 0.7272
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A showAccountAction() 6 21 3

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 AppBundle\Controller\Admin;
4
5
use AppBundle\Entity\ModuleUser;
6
use AppBundle\Entity\User;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\HttpFoundation\Response;
12
13
class AdminInfoUsersController extends Controller
14
{
15
    /**
16
     * @Route("/admin/account/{id}", name="admin_account")
17
     * @Template("@App/admin/AdminInfoUsers/showAccount.html.twig")
18
     */
19 1
    public function showAccountAction(Request $request, User $id = null)
20
    {
21 1
        $em = $this->getDoctrine()->getManager();
22
23 1
        $request->get('module') ? $module = $request->get('module') : $module = null;
24
25 1 View Code Duplication
        if ($module) {
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...
26
            $moduleAjax = $em->getRepository('AppBundle:PassModule')
27
                ->findAjax($module);
28
29
            return new Response(json_encode(['moduleAjax' => $moduleAjax]));
30
        }
31
32 1
        $modules = $em->getRepository('AppBundle:ModuleUser')
33 1
            ->findModules($id);
34
35
        return [
36 1
            'user' => $id,
37
            'modules' => $modules
38 1
        ];
39
    }
40
}
41