| Conditions | 3 |
| Paths | 4 |
| Total Lines | 108 |
| Code Lines | 78 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 2 |
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 |
||
| 61 | public function buildUserMenu(FactoryInterface $factory, array $options) |
||
| 62 | { |
||
| 63 | $menu = $factory->createItem('root'); |
||
| 64 | $menu->setChildrenAttribute('class', 'nav navbar-nav navbar-right'); |
||
| 65 | |||
| 66 | $context = $this->container->get('security.context'); |
||
| 67 | if ($context->isGranted('IS_AUTHENTICATED_REMEMBERED')) { |
||
| 68 | /* |
||
| 69 | * Menu Administration |
||
| 70 | */ |
||
| 71 | $menu->addChild('entities', array('label' => 'menu.configuration')) |
||
| 72 | ->setExtra('translation_domain', 'messages') |
||
| 73 | ->setAttribute('dropdown', true) |
||
| 74 | ->setAttribute('class', 'multi-level') |
||
| 75 | ->setAttribute('icon', 'glyphicon glyphicon-cog'); |
||
| 76 | |||
| 77 | $menu['entities'] |
||
| 78 | ->addChild('company', array( |
||
| 79 | 'route' => 'admin_company', |
||
| 80 | 'label' => 'gestock.settings.company.title' |
||
| 81 | )) |
||
| 82 | ->setExtra('translation_domain', 'messages') |
||
| 83 | ->setAttribute('icon', 'glyphicon glyphicon-tower'); |
||
| 84 | |||
| 85 | $menu['entities'] |
||
| 86 | ->addChild('applcation', array( |
||
| 87 | 'route' => 'admin_application', |
||
| 88 | 'label' => 'gestock.settings.application.title' |
||
| 89 | )) |
||
| 90 | ->setExtra('translation_domain', 'messages') |
||
| 91 | ->setAttribute('icon', 'glyphicon glyphicon-wrench'); |
||
| 92 | |||
| 93 | $divers = $menu['entities'] |
||
| 94 | ->addChild('divers', array('label' => 'gestock.settings.diverse.title')) |
||
| 95 | ->setExtra('translation_domain', 'messages') |
||
| 96 | ->setAttribute('dropdown', true) |
||
| 97 | ->setAttribute('class', 'dropdown-submenu') |
||
| 98 | ->setAttribute('icon', 'glyphicon glyphicon-info-sign'); |
||
| 99 | |||
| 100 | $divers |
||
| 101 | ->addChild('familylog', array( |
||
| 102 | 'route' => 'admin_familylog', |
||
| 103 | 'label' => 'gestock.settings.diverse.familylog' |
||
| 104 | )) |
||
| 105 | ->setAttribute('icon', 'glyphicon glyphicon-tag'); |
||
| 106 | |||
| 107 | $divers |
||
| 108 | ->addChild('zonestorage', array( |
||
| 109 | 'route' => 'admin_zonestorage', |
||
| 110 | 'label' => 'gestock.settings.diverse.zonestorage' |
||
| 111 | )) |
||
| 112 | ->setAttribute('icon', 'glyphicon glyphicon-map-marker'); |
||
| 113 | |||
| 114 | $divers |
||
| 115 | ->addChild('unitstorage', array( |
||
| 116 | 'route' => 'admin_unitstorage', |
||
| 117 | 'label' => 'gestock.settings.diverse.unitstorage' |
||
| 118 | )) |
||
| 119 | ->setAttribute('icon', 'fa fa-cubes'); |
||
| 120 | |||
| 121 | $divers |
||
| 122 | ->addChild('tva', array( |
||
| 123 | 'route' => 'admin_rate', |
||
| 124 | 'label' => 'gestock.settings.diverse.vat' |
||
| 125 | )) |
||
| 126 | ->setAttribute('icon', 'glyphicon glyphicon-piggy-bank'); |
||
| 127 | |||
| 128 | $menu['entities'] |
||
| 129 | ->addChild('divider') |
||
| 130 | ->setAttribute('class', 'divider'); |
||
| 131 | |||
| 132 | $menu['entities'] |
||
| 133 | ->addChild('users', array( |
||
| 134 | 'route' => 'admin_users', |
||
| 135 | 'label' => 'menu.users')) |
||
| 136 | ->setAttribute('icon', 'glyphicon glyphicon-user'); |
||
| 137 | |||
| 138 | $menu['entities'] |
||
| 139 | ->addChild('groups', array( |
||
| 140 | 'route' => 'admin_groups', |
||
| 141 | 'label' => 'menu.groups')) |
||
| 142 | ->setAttribute('icon', 'fa fa-users'); |
||
| 143 | } |
||
| 144 | /* |
||
| 145 | * Menu Profile |
||
| 146 | */ |
||
| 147 | if ($context->isGranted('IS_AUTHENTICATED_REMEMBERED')) { |
||
| 148 | $menu->addChild('profile', array( |
||
| 149 | 'label' => $context->getToken()->getUser()->getUsername())) |
||
| 150 | ->setAttribute('dropdown', true) |
||
| 151 | ->setAttribute('icon', 'fa fa-user'); |
||
| 152 | |||
| 153 | $menu['profile']->addChild('layout.logout', array('route' => 'fos_user_security_logout')) |
||
| 154 | ->setExtra('translation_domain', 'FOSUserBundle') |
||
| 155 | ->setAttribute('icon', 'fa fa-unlink'); |
||
| 156 | } else { |
||
| 157 | $menu->addChild('profile', array( |
||
| 158 | 'label' => 'menu.administration' |
||
| 159 | )) |
||
| 160 | ->setExtra('translation_domain', 'messages') |
||
| 161 | ->setAttribute('dropdown', true) |
||
| 162 | ->setAttribute('icon', 'fa fa-user'); |
||
| 163 | } |
||
| 164 | $menu['profile']->addChild('menu.other_login', array('route' => 'fos_user_security_login')) |
||
| 165 | ->setAttribute('icon', 'fa fa-link'); |
||
| 166 | |||
| 167 | return $menu; |
||
| 168 | } |
||
| 169 | } |
||
| 170 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.