Conditions | 15 |
Paths | 864 |
Total Lines | 60 |
Code Lines | 39 |
Lines | 60 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
106 | View Code Duplication | protected function redirectTo($object) |
|
107 | { |
||
108 | $request = $this->getRequest(); |
||
109 | |||
110 | $url = false; |
||
111 | $params = []; |
||
112 | |||
113 | if ($object instanceof Item) { |
||
114 | if ($object->getParent() !== null) { |
||
115 | $itemId = $object->getParent()->getId(); |
||
116 | $params['list']['item'] = $itemId; |
||
117 | $params['create']['create-item'] = $itemId; |
||
118 | } |
||
119 | $menuId = $object->getMenu()->getId(); |
||
120 | $params['list']['menu'] = $menuId; |
||
121 | $params['create']['create-menu'] = $menuId; |
||
122 | } elseif ($object instanceof Menu) { |
||
123 | $menuId = $object->getId(); |
||
124 | $params['list']['menu'] = $menuId; |
||
125 | $params['create']['create-menu'] = $menuId; |
||
126 | } |
||
127 | |||
128 | if (null !== $request->get('btn_update_and_list')) { |
||
129 | $url = $this->admin->generateUrl('list', $params['list']); |
||
130 | } elseif (null !== $request->get('btn_create_and_list')) { |
||
131 | $url = $this->admin->generateUrl('list', $params['list']); |
||
132 | } |
||
133 | |||
134 | if (null !== $request->get('btn_create_and_create')) { |
||
135 | if ($this->admin->hasActiveSubClass()) { |
||
136 | $params['create']['subclass'] = $request->get('subclass'); |
||
137 | } |
||
138 | $url = $this->admin->generateUrl('create', $params['create']); |
||
139 | } |
||
140 | |||
141 | if ($this->getRestMethod() === 'DELETE') { |
||
142 | if ($object instanceof Item) { |
||
143 | $url = $this->admin->generateUrl('list', $params['list']); |
||
144 | } else { |
||
145 | $router = $this->get('router'); |
||
146 | $url = $router->generate('admin_alpixel_menu_menu_list'); |
||
147 | } |
||
148 | } |
||
149 | |||
150 | if (!$url) { |
||
151 | foreach (['edit', 'show'] as $route) { |
||
152 | if ($this->admin->hasRoute($route) && $this->admin->isGranted(strtoupper($route), $object)) { |
||
153 | $url = $this->admin->generateObjectUrl($route, $object); |
||
154 | break; |
||
155 | } |
||
156 | } |
||
157 | } |
||
158 | |||
159 | if (!$url) { |
||
160 | $router = $this->get('router'); |
||
161 | $url = $router->generate('admin_alpixel_menu_menu_list'); |
||
162 | } |
||
163 | |||
164 | return new RedirectResponse($url); |
||
165 | } |
||
166 | |||
185 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.