Completed
Push — Recipes ( 630f49...c8afb0 )
by Laurent
12:15 queued 03:48
created

ApplicationController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 144
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 1
dl 144
loc 144
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 6 6 1
A showAction() 6 6 1
A newAction() 11 11 1
A createAction() 12 12 1
A editAction() 10 10 1
A updateAction() 11 11 1
A deleteAction() 10 10 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
 * ApplicationController Configuration controller of the application.
4
 *
5
 * PHP Version 7
6
 *
7
 * @author    Quétier Laurent <[email protected]>
8
 * @copyright 2014 Dev-Int GLSR
9
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
10
 *
11
 * @version GIT: <git_id>
12
 *
13
 * @link      https://github.com/Dev-Int/glsr
14
 */
15
namespace App\Controller\Settings;
16
17
use App\Controller\AbstractAppController;
18
use Symfony\Component\HttpFoundation\Request;
19
use Symfony\Component\Routing\Annotation\Route;
20
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
21
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
22
use App\Entity\Settings\Settings;
23
use App\Form\Type\Settings\SettingsType;
24
25
/**
26
 * Application controller.
27
 *
28
 * @category Controller
29
 *
30
 * @Route("/admin/settings/application")
31
 */
32 View Code Duplication
class ApplicationController extends AbstractAppController
33
{
34
    /**
35
     * Lists all Settings entities.
36
     *
37
     * @Route("/", name="application")
38
     * @Method("GET")
39
     * @Template()
40
     *
41
     * @return array
42
     */
43
    public function indexAction()
44
    {
45
        $return = $this->abstractIndexAction('Settings\Settings', 'settings', null);
46
    
47
        return $return;
48
    }
49
50
    /**
51
     * Finds and displays a Settings entity.
52
     *
53
     * @Route("/{id}/show", name="settings_show", requirements={"id"="\d+"})
54
     * @Method("GET")
55
     * @Template()
56
     *
57
     * @param \App\Entity\Settings\Settings $settings Settings item to display
58
     * @return array
59
     */
60
    public function showAction(Settings $settings)
61
    {
62
        $return = $this->abstractShowAction($settings, 'settings');
63
64
        return $return;
65
    }
66
67
    /**
68
     * Displays a form to create a new Settings entity.
69
     *
70
     * @Route("/new", name="settings_new")
71
     * @Method("GET")
72
     * @Template()
73
     *
74
     * @return array
75
     */
76
    public function newAction()
77
    {
78
        $return = $this->abstractNewAction(
79
            'Settings\Settings',
80
            'App\Entity\Settings\Settings',
81
            SettingsType::class,
82
            'settings'
83
        );
84
85
        return $return;
86
    }
87
88
    /**
89
     * Creates a new Settings entity.
90
     *
91
     * @Route("/create", name="settings_create")
92
     * @Method("POST")
93
     * @Template("settings/application/new.html.twig")
94
     *
95
     * @param \Symfony\Component\HttpFoundation\Request $request Form request
96
     * @return array
97
     */
98
    public function createAction(Request $request)
99
    {
100
        $return = $this->abstractCreateAction(
101
            $request,
102
            'Settings\Settings',
103
            'App\Entity\Settings\Settings',
104
            SettingsType::class,
105
            'settings'
106
        );
107
108
        return $return;
109
    }
110
111
    /**
112
     * Displays a form to edit an existing Settings entity.
113
     *
114
     * @Route("/{id}/edit", name="settings_edit", requirements={"id"="\d+"})
115
     * @Method("GET")
116
     * @Template()
117
     *
118
     * @param \App\Entity\Settings\Settings $settings Settings item to edit
119
     * @return array
120
     */
121
    public function editAction(Settings $settings)
122
    {
123
        $return = $this->abstractEditAction(
124
            $settings,
125
            'settings',
126
            SettingsType::class
127
        );
128
129
        return $return;
130
    }
131
132
    /**
133
     * Edits an existing Settings entity.
134
     *
135
     * @Route("/{id}/update", name="settings_update", requirements={"id"="\d+"})
136
     * @Method("PUT")
137
     * @Template("settings/spplication/edit.html.twig")
138
     *
139
     * @param \App\Entity\Settings\Settings             $settings Settings item to update
140
     * @param \Symfony\Component\HttpFoundation\Request $request  Form request
141
     * @return array
142
     */
143
    public function updateAction(Settings $settings, Request $request)
144
    {
145
        $return = $this->abstractUpdateAction(
146
            $settings,
147
            $request,
148
            'settings',
149
            SettingsType::class
150
        );
151
152
        return $return;
153
    }
154
155
    /**
156
     * Deletes a Settings entity.
157
     *
158
     * @Route("/{id}/delete", name="settings_delete", requirements={"id"="\d+"})
159
     * @Method("DELETE")
160
     *
161
     * @param \App\Entity\Settings\Settings             $settings Settings item to delete
162
     * @param \Symfony\Component\HttpFoundation\Request $request  Form request
163
     * @return array
164
     */
165
    public function deleteAction(Settings $settings, Request $request)
166
    {
167
        $this->abstractDeleteAction(
168
            $settings,
169
            $request,
170
            'settings'
171
        );
172
173
        return $this->redirectToRoute('application');
174
    }
175
}
176