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