Completed
Pull Request — master (#168)
by
unknown
02:59
created

SettingsAddController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 26.92 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 3
Metric Value
wmc 3
c 4
b 0
f 3
lcom 0
cbo 1
dl 7
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A displayAction() 7 18 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
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[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 ONGR\SettingsBundle\Controller;
13
14
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
15
use Symfony\Component\HttpFoundation\Response;
16
17
/**
18
 * Class SettingsListController. Is used for managing settings in General env.
19
 */
20
class SettingsAddController extends Controller
21
{
22
    /**
23
     * Renders add setting form.
24
     *
25
     * @return Response
26
     */
27
    public function displayAction()
28
    {
29
        $profileManager = $this->get('ongr_settings.profiles_manager');
30
        $profiles = $profileManager->getAllProfiles();
31
        $params = [];
32
        $params['profiles'] = $profiles;
33
        $cache = $this->get('es.cache_engine');
34 View Code Duplication
        if ($cache->contains('settings_errors')) {
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...
35
            $params['errors'] = $cache->fetch('settings_errors');
36
            $cache->delete('settings_errors');
37
        } elseif ($cache->contains('settings_success')) {
38
            $params['success'] = $cache->fetch('settings_success');
39
            $cache->delete('settings_success');
40
        }
41
        return $this->render(
42
            'ONGRSettingsBundle:Settings:add.html.twig', $params
43
        );
44
    }
45
}
46