ACPDashboardController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 38.3 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 5
Bugs 0 Features 5
Metric Value
wmc 3
c 5
b 0
f 5
lcom 1
cbo 1
dl 18
loc 47
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setBreadcrumbs() 0 4 1
A indexAction() 0 9 1
A assignVariables() 18 18 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
/*
4
 * This file is part of the 2martens Web Platform.
5
 *
6
 * (c) Jim Martens <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace TwoMartens\Bundle\CoreBundle\Controller;
13
14
use Symfony\Component\HttpFoundation\Response;
15
16
/**
17
 * Manages the routes for the ACP dashboard.
18
 *
19
 * @author Jim Martens <[email protected]>
20
 */
21
class ACPDashboardController extends AbstractACPController
22
{
23
    /**
24
     * Shows the dashboard/landing site of the ACP.
25
     *
26
     * @return Response
27
     */
28
    public function indexAction()
29
    {
30
        $this->assignVariables();
31
32
        return $this->render(
33
            'TwoMartensCoreBundle:ACPDashboard:index.html.twig',
34
            $this->templateVariables
35
        );
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected function setBreadcrumbs()
42
    {
43
        // no breadcrumbs needed on ACP Dashboard
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 View Code Duplication
    protected function assignVariables()
50
    {
51
        $this->templateVariables = array(
52
            'area' => array(
53
                'showBreadcrumbs' => false,
54
                'title' => $this->get('translator')->trans('acp.dashboard', array(), 'TwoMartensCoreBundle')
55
            ),
56
            'siteTitle' => $this->get('translator')->trans(
57
                'acp.siteTitle',
58
                array('globalTitle' => 'CoreBundle Test'),
59
                'TwoMartensCoreBundle'
60
            ),
61
            'navigation' => array(
62
                'active' => 'home'
63
            ),
64
        );
65
        parent::assignVariables();
66
    }
67
}
68