| Conditions | 12 |
| Paths | 96 |
| Total Lines | 38 |
| Code Lines | 21 |
| Lines | 38 |
| Ratio | 100 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 84 | View Code Duplication | protected function redirectTo($object) |
|
| 85 | { |
||
| 86 | $request = $this->getRequest(); |
||
| 87 | |||
| 88 | $url = $backToNodeList = false; |
||
| 89 | $instanceAdmin = $this->admin->getConfigurationPool()->getInstance('alpixel_cms.admin.node'); |
||
| 90 | |||
| 91 | if (null !== $request->get('btn_update_and_list') || null !== $request->get('btn_create_and_list')) { |
||
| 92 | $backToNodeList = true; |
||
| 93 | } |
||
| 94 | |||
| 95 | if (null !== $request->get('btn_create_and_create')) { |
||
| 96 | $params = []; |
||
| 97 | if ($this->admin->hasActiveSubClass()) { |
||
| 98 | $params['subclass'] = $request->get('subclass'); |
||
| 99 | } |
||
| 100 | $url = $this->admin->generateUrl('create', $params); |
||
| 101 | } |
||
| 102 | |||
| 103 | if ($this->getRestMethod() === 'DELETE') { |
||
| 104 | $backToNodeList = true; |
||
| 105 | } |
||
| 106 | |||
| 107 | if (!$url) { |
||
| 108 | foreach (['edit', 'show'] as $route) { |
||
| 109 | if ($this->admin->hasRoute($route) && $this->admin->isGranted(strtoupper($route), $object)) { |
||
| 110 | $url = $this->admin->generateObjectUrl($route, $object); |
||
| 111 | break; |
||
| 112 | } |
||
| 113 | } |
||
| 114 | } |
||
| 115 | |||
| 116 | if ($backToNodeList || !$url) { |
||
| 117 | $url = $instanceAdmin->generateUrl('list'); |
||
| 118 | } |
||
| 119 | |||
| 120 | return new RedirectResponse($url); |
||
| 121 | } |
||
| 122 | } |
||
| 123 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.