Conditions | 12 |
Paths | 96 |
Total Lines | 38 |
Lines | 18 |
Ratio | 47.37 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
107 | protected function redirectTo($object) |
||
108 | { |
||
109 | $request = $this->getRequest(); |
||
110 | |||
111 | $url = $backToNodeList = false; |
||
112 | $instanceAdmin = $this->admin->getConfigurationPool()->getInstance('alpixel_cms.admin.block'); |
||
113 | |||
114 | View Code Duplication | if (null !== $request->get('btn_update_and_list') || null !== $request->get('btn_create_and_list')) { |
|
115 | $backToNodeList = true; |
||
116 | } |
||
117 | |||
118 | View Code Duplication | if (null !== $request->get('btn_create_and_create')) { |
|
119 | $params = []; |
||
120 | if ($this->admin->hasActiveSubClass()) { |
||
121 | $params['subclass'] = $request->get('subclass'); |
||
122 | } |
||
123 | $url = $this->admin->generateUrl('create', $params); |
||
124 | } |
||
125 | |||
126 | if ($this->getRestMethod() === 'DELETE') { |
||
127 | $backToNodeList = true; |
||
128 | } |
||
129 | |||
130 | View Code Duplication | if (!$url) { |
|
131 | foreach (['edit', 'show'] as $route) { |
||
132 | if ($this->admin->hasRoute($route) && $this->admin->isGranted(strtoupper($route), $object)) { |
||
133 | $url = $this->admin->generateObjectUrl($route, $object); |
||
134 | break; |
||
135 | } |
||
136 | } |
||
137 | } |
||
138 | |||
139 | if ($backToNodeList || !$url) { |
||
140 | $url = $instanceAdmin->generateUrl('list'); |
||
141 | } |
||
142 | |||
143 | return new RedirectResponse($url); |
||
144 | } |
||
145 | } |
||
146 |
This check marks private properties in classes that are never used. Those properties can be removed.