| Conditions | 2 |
| Paths | 2 |
| Total Lines | 61 |
| Code Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 8 | public function settingsMenu(array $options = [ ]): ItemInterface { |
||
|
|
|||
| 9 | $root = $this->factory->createItem('root'); |
||
| 10 | |||
| 11 | if($this->authorizationChecker->isGranted('ROLE_ADMIN')) { |
||
| 12 | $root->addChild('admin.settings.general.label', [ |
||
| 13 | 'route' => 'admin_settings_general' |
||
| 14 | ]) |
||
| 15 | ->setExtra('icon', 'fas fa-wrench'); |
||
| 16 | |||
| 17 | $root->addChild('admin.settings.dashboard.label', [ |
||
| 18 | 'route' => 'admin_settings_dashboard' |
||
| 19 | ]) |
||
| 20 | ->setExtra('icon', 'fas fa-home'); |
||
| 21 | |||
| 22 | $root->addChild('admin.settings.notifications.label', [ |
||
| 23 | 'route' => 'admin_settings_notifications' |
||
| 24 | ]) |
||
| 25 | ->setExtra('icon', 'fas fa-bell'); |
||
| 26 | |||
| 27 | $root->addChild('admin.settings.timetable.label', [ |
||
| 28 | 'route' => 'admin_settings_timetable' |
||
| 29 | ]) |
||
| 30 | ->setExtra('icon', 'fas fa-clock'); |
||
| 31 | |||
| 32 | $root->addChild('admin.settings.substitutions.label', [ |
||
| 33 | 'route' => 'admin_settings_substitutions' |
||
| 34 | ]) |
||
| 35 | ->setExtra('icon', 'fas fa-random'); |
||
| 36 | |||
| 37 | $root->addChild('admin.settings.exams.label', [ |
||
| 38 | 'route' => 'admin_settings_exams' |
||
| 39 | ]) |
||
| 40 | ->setExtra('icon', 'fas fa-edit'); |
||
| 41 | |||
| 42 | $root->addChild('admin.settings.appointments.label', [ |
||
| 43 | 'route' => 'admin_settings_appointments' |
||
| 44 | ]) |
||
| 45 | ->setExtra('icon', 'far fa-calendar'); |
||
| 46 | |||
| 47 | $root->addChild('admin.settings.student_absences.label', [ |
||
| 48 | 'route' => 'admin_settings_absences' |
||
| 49 | ]) |
||
| 50 | ->setExtra('icon', 'fas fa-user-times'); |
||
| 51 | |||
| 52 | $root->addChild('admin.settings.book.label', [ |
||
| 53 | 'route' => 'admin_settings_book' |
||
| 54 | ]) |
||
| 55 | ->setExtra('icon', 'fas fa-book-open'); |
||
| 56 | |||
| 57 | $root->addChild('admin.settings.tuition_grades.label', [ |
||
| 58 | 'route' => 'admin_settings_gradebook' |
||
| 59 | ]) |
||
| 60 | ->setExtra('icon', 'fas fa-user-graduate'); |
||
| 61 | |||
| 62 | $root->addChild('admin.settings.import.label', [ |
||
| 63 | 'route' => 'admin_settings_import' |
||
| 64 | ]) |
||
| 65 | ->setExtra('icon', 'fas fa-upload'); |
||
| 66 | } |
||
| 67 | |||
| 68 | return $root; |
||
| 69 | } |
||
| 70 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.