| Conditions | 15 | 
| Paths | 864 | 
| Total Lines | 61 | 
| Code Lines | 39 | 
| Lines | 0 | 
| Ratio | 0 % | 
| 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  | 
            ||
| 31 | protected function redirectTo($object)  | 
            ||
| 32 |     { | 
            ||
| 33 | $request = $this->getRequest();  | 
            ||
| 34 | |||
| 35 | $url = false;  | 
            ||
| 36 | $params = [];  | 
            ||
| 37 | |||
| 38 |         if ($object instanceof Item) { | 
            ||
| 39 |             if ($object->getParent() !== null) { | 
            ||
| 40 | $itemId = $object->getParent()->getId();  | 
            ||
| 41 | $params['list']['item'] = $itemId;  | 
            ||
| 42 | $params['create']['create-item'] = $itemId;  | 
            ||
| 43 | }  | 
            ||
| 44 | $menuId = $object->getMenu()->getId();  | 
            ||
| 45 | $params['list']['menu'] = $menuId;  | 
            ||
| 46 | $params['create']['create-menu'] = $menuId;  | 
            ||
| 47 |         } elseif ($object instanceof Menu) { | 
            ||
| 48 | $menuId = $object->getId();  | 
            ||
| 49 | $params['list']['menu'] = $menuId;  | 
            ||
| 50 | $params['create']['create-menu'] = $menuId;  | 
            ||
| 51 | }  | 
            ||
| 52 | |||
| 53 |         if (null !== $request->get('btn_update_and_list')) { | 
            ||
| 54 |             $url = $this->admin->generateUrl('list', $params['list']); | 
            ||
| 55 |         } elseif (null !== $request->get('btn_create_and_list')) { | 
            ||
| 56 |             $url = $this->admin->generateUrl('list', $params['list']); | 
            ||
| 57 | }  | 
            ||
| 58 | |||
| 59 |         if (null !== $request->get('btn_create_and_create')) { | 
            ||
| 60 |             if ($this->admin->hasActiveSubClass()) { | 
            ||
| 61 |                 $params['create']['subclass'] = $request->get('subclass'); | 
            ||
| 62 | }  | 
            ||
| 63 |             $url = $this->admin->generateUrl('create', $params['create']); | 
            ||
| 64 | }  | 
            ||
| 65 | |||
| 66 |         if ($this->getRestMethod() === 'DELETE') { | 
            ||
| 67 |             if ($object instanceof Item) { | 
            ||
| 68 |                 $url = $this->admin->generateUrl('list', $params['list']); | 
            ||
| 69 | }  | 
            ||
| 70 |             else { | 
            ||
| 71 |                 $router = $this->get('router'); | 
            ||
| 72 |                 $url= $router->generate('admin_alpixel_menu_menu_list'); | 
            ||
| 73 | }  | 
            ||
| 74 | }  | 
            ||
| 75 | |||
| 76 |         if (!$url) { | 
            ||
| 77 |             foreach (array('edit', 'show') as $route) { | 
            ||
| 78 |                 if ($this->admin->hasRoute($route) && $this->admin->isGranted(strtoupper($route), $object)) { | 
            ||
| 79 | $url = $this->admin->generateObjectUrl($route, $object);  | 
            ||
| 80 | break;  | 
            ||
| 81 | }  | 
            ||
| 82 | }  | 
            ||
| 83 | }  | 
            ||
| 84 | |||
| 85 |         if (!$url) { | 
            ||
| 86 |             $router = $this->get('router'); | 
            ||
| 87 |             $url= $router->generate('admin_alpixel_menu_menu_list'); | 
            ||
| 88 | }  | 
            ||
| 89 | |||
| 90 | return new RedirectResponse($url);  | 
            ||
| 91 | }  | 
            ||
| 92 | }  | 
            ||
| 93 |