| Conditions | 6 |
| Paths | 13 |
| Total Lines | 58 |
| Code Lines | 31 |
| 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 |
||
| 136 | public function skillsMenu(FactoryInterface $factory, array $options) |
||
| 137 | { |
||
| 138 | $checker = $this->container->get('security.authorization_checker'); |
||
| 139 | $translator = $this->container->get('translator'); |
||
| 140 | $settingsManager = $this->container->get('chamilo.settings.manager'); |
||
| 141 | //$allow = $settingsManager->getSetting('hide_my_certificate_link'); |
||
| 142 | $allow = api_get_configuration_value('hide_my_certificate_link'); |
||
| 143 | |||
| 144 | $menu = $factory->createItem('root'); |
||
| 145 | if ($checker->isGranted('IS_AUTHENTICATED_FULLY')) { |
||
| 146 | $menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); |
||
| 147 | |||
| 148 | if ($allow == false) { |
||
| 149 | $menu->addChild( |
||
| 150 | $translator->trans('MyCertificates'), |
||
| 151 | [ |
||
| 152 | 'route' => 'main', |
||
| 153 | 'routeParameters' => ['name' => 'gradebook/my_certificates.php'], |
||
| 154 | ] |
||
| 155 | ); |
||
| 156 | } |
||
| 157 | |||
| 158 | if ($settingsManager->getSetting( |
||
| 159 | 'allow_public_certificates' |
||
| 160 | ) === 'true' |
||
| 161 | ) { |
||
| 162 | $menu->addChild( |
||
| 163 | $translator->trans('Search'), |
||
| 164 | [ |
||
| 165 | 'route' => 'main', |
||
| 166 | 'routeParameters' => ['name' => 'gradebook/search.php'], |
||
| 167 | ] |
||
| 168 | ); |
||
| 169 | } |
||
| 170 | |||
| 171 | if ($settingsManager->getSetting('allow_skills_tool') === 'true') { |
||
| 172 | $menu->addChild( |
||
| 173 | $translator->trans('MySkills'), |
||
| 174 | [ |
||
| 175 | 'route' => 'main', |
||
| 176 | 'routeParameters' => ['name' => 'social/my_skills_report.php'], |
||
| 177 | ] |
||
| 178 | ); |
||
| 179 | |||
| 180 | if ($checker->isGranted('ROLE_TEACHER')) { |
||
| 181 | $menu->addChild( |
||
| 182 | $translator->trans('ManageSkills'), |
||
| 183 | [ |
||
| 184 | 'route' => 'main', |
||
| 185 | 'routeParameters' => ['name' => 'admin/skills_wheel.php'], |
||
| 186 | ] |
||
| 187 | ); |
||
| 188 | } |
||
| 189 | } |
||
| 190 | } |
||
| 191 | |||
| 192 | return $menu; |
||
| 193 | } |
||
| 194 | } |
||
| 195 |