| Conditions | 2 |
| Paths | 2 |
| Total Lines | 116 |
| Code Lines | 82 |
| 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 |
||
| 57 | protected function addFields() |
||
| 58 | { |
||
| 59 | $W = bab_Widgets(); |
||
| 60 | |||
| 61 | $this->addItem($W->Acl()->setTitle(absences_translate('Vacations mangers'))->setName('managers')); |
||
| 62 | |||
| 63 | if (null !== bab_OCgetPrimaryOcId()) |
||
| 64 | { |
||
| 65 | $this->addItem($this->id_chart()); |
||
| 66 | } |
||
| 67 | |||
| 68 | $this->addItem($this->boolfield('chart_superiors_create_request', absences_translate("Allow delegated managers to create vacation requests for users in chart"))); |
||
| 69 | $this->addItem($this->boolfield('chart_superiors_set_rights', absences_translate("Allow delegated managers to update vacations rights for users in chart"))); |
||
| 70 | $this->addItem($this->boolfield('chart_superiors_user_edit', absences_translate("Allow delegated managers to update users settings for users in chart"))); |
||
| 71 | $this->addItem($this->boolfield('allow_mismatch', absences_translate("Allow users to create vacation requests with mismatch in total number of days"))); |
||
| 72 | $this->addItem($this->boolfield('workperiod_recover_request', absences_translate("Allow users to create workperiods request recovery"))); |
||
| 73 | $this->addItem($this->boolfield('display_personal_history', absences_translate("Users can access to the personal history"))); |
||
| 74 | $this->addItem($this->boolfield('modify_confirmed', absences_translate("Users can edit or delete confirmed requests"))); |
||
| 75 | $this->addItem($this->boolfield('modify_waiting', absences_translate("Users can edit or delete waiting requests"))); |
||
| 76 | $this->addItem($this->boolfield('email_manager_ondelete', absences_translate('Notify managers when a vacation request is deleted'))); |
||
| 77 | $this->addItem($this->boolfield('approb_email_defer', absences_translate('Use defered approbation email (daily notification)'), |
||
| 78 | absences_translate('The notification is sent every day between 12:00 and 13:00 to all approvers with waiting items'))); |
||
| 79 | $this->addItem($this->boolfield('user_add_email', absences_translate('Allow users to notify emails about the accepted vacations requests'))); |
||
| 80 | |||
| 81 | |||
| 82 | $this->addItem($W->Acl()->setTitle(absences_translate('Who can view the public calendar?'))->setName('public_planning')); |
||
| 83 | |||
| 84 | $this->addItem($this->boolfield('appliquant_email', absences_translate('Send an email to appliquant when a request is confirmed'))); |
||
| 85 | |||
| 86 | $this->addItem($W->LabelledWidget( |
||
| 87 | absences_translate('Alert for waiting request not modified in more than'), |
||
| 88 | $W->LineEdit()->setSize(3)->setMaxSize(3), |
||
| 89 | 'approb_alert', |
||
| 90 | absences_translate('Requests exceeding this period will be displayed in red in the email sent to approvers and displayed as bold in the manager waiting requests list, no additional mail are sent with this parameter'), |
||
| 91 | absences_translate('days') |
||
| 92 | )); |
||
| 93 | |||
| 94 | $this->addItem($this->boolfield('auto_approval', absences_translate('Auto approve if current user is responsible of the first approval step'))); |
||
| 95 | |||
| 96 | $this->addItem($W->LabelledWidget( |
||
| 97 | absences_translate('Auto confirm waiting request not modified in more than'), |
||
| 98 | $W->LineEdit()->setSize(3)->setMaxSize(3), |
||
| 99 | 'auto_confirm', |
||
| 100 | null, |
||
| 101 | absences_translate('days') |
||
| 102 | )); |
||
| 103 | |||
| 104 | $this->addItem($W->LabelledWidget( |
||
| 105 | absences_translate('End of avaibility for the recuperation in days after the working periode'), |
||
| 106 | $W->LineEdit()->setSize(3)->setMaxSize(3), |
||
| 107 | 'end_recup', |
||
| 108 | null, |
||
| 109 | absences_translate('days') |
||
| 110 | )); |
||
| 111 | |||
| 112 | $this->addItem($W->LabelledWidget( |
||
| 113 | absences_translate("Anticipation delay for the recovery period deposit"), |
||
| 114 | $W->LineEdit()->setSize(3)->setMaxSize(3), |
||
| 115 | 'delay_recovery', |
||
| 116 | null, |
||
| 117 | absences_translate('days') |
||
| 118 | )); |
||
| 119 | |||
| 120 | $months = array( |
||
| 121 | 1 => absences_translate('January'), |
||
| 122 | 2 => absences_translate('February'), |
||
| 123 | 3 => absences_translate('March'), |
||
| 124 | 4 => absences_translate('April'), |
||
| 125 | 5 => absences_translate('May'), |
||
| 126 | 6 => absences_translate('June'), |
||
| 127 | 7 => absences_translate('July'), |
||
| 128 | 8 => absences_translate('August'), |
||
| 129 | 9 => absences_translate('September'), |
||
| 130 | 10 => absences_translate('October'), |
||
| 131 | 11 => absences_translate('November'), |
||
| 132 | 12 => absences_translate('December') |
||
| 133 | ); |
||
| 134 | |||
| 135 | $this->addItem( |
||
| 136 | $W->VBoxItems( |
||
| 137 | $W->Label(absences_translate('The day when the periode is changing') . ' :')->addClass('widget-description'), |
||
| 138 | $W->FlowItems( |
||
| 139 | $W->LineEdit()->setSize(2)->setMaxSize(2)->setName('archivage_day'), |
||
| 140 | $W->Select()->setOptions($months)->setName('archivage_month') |
||
| 141 | ) |
||
| 142 | ) |
||
| 143 | ); |
||
| 144 | |||
| 145 | $this->addItem($this->boolfield('entity_planning', absences_translate("Allow chart members to access the entity planning of their main entity"))); |
||
| 146 | $this->addItem($this->boolfield('entity_planning_display_types', absences_translate("Display types and legend for all users in the entity planning, instead of entity responsible and managers only"))); |
||
| 147 | $this->addItem($this->boolfield('maintenance', absences_translate("Use mainteance mode, only managers can create or modify requests"))); |
||
| 148 | $this->addItem($this->organization_sync()); |
||
| 149 | $this->addItem($this->boolfield('sync_server', absences_translate("This server act as a synchronization server"))); |
||
| 150 | |||
| 151 | $client = $W->Frame(null, $W->VBoxLayout()->setVerticalSpacing(1,'em')); |
||
| 152 | |||
| 153 | $client->addItem($W->LabelledWidget( |
||
| 154 | absences_translate('Shared rights server url'), |
||
| 155 | $W->LineEdit()->setSize(40)->setMaxSize(255), |
||
| 156 | 'sync_url' |
||
| 157 | )); |
||
| 158 | |||
| 159 | $client->addItem($W->LabelledWidget( |
||
| 160 | absences_translate('Nickname'), |
||
| 161 | $W->LineEdit()->setSize(20)->setMaxSize(255), |
||
| 162 | 'sync_nickname' |
||
| 163 | )); |
||
| 164 | |||
| 165 | $client->addItem($W->LabelledWidget( |
||
| 166 | absences_translate('Password'), |
||
| 167 | $W->LineEdit()->setSize(20)->setMaxSize(255), |
||
| 168 | 'sync_password' |
||
| 169 | )); |
||
| 170 | |||
| 171 | $this->addItem($W->Section(absences_translate('This server act as a synchronization client'), $client)->setFoldable(true, true)); |
||
| 172 | } |
||
| 173 | |||
| 242 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.