| Conditions | 4 |
| Paths | 8 |
| Total Lines | 61 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 124 | public function install() |
||
| 125 | { |
||
| 126 | $extraField = new ExtraField('exercise'); |
||
| 127 | $extraFieldHandler = $extraField->get_handler_field_info_by_field_variable('signature_activated'); |
||
| 128 | $exists = $extraFieldHandler !== false; |
||
| 129 | |||
| 130 | if (!$exists) { |
||
| 131 | $extraField->save( |
||
| 132 | [ |
||
| 133 | 'field_type' => 13, // checkbox yes/no |
||
| 134 | 'variable' => 'signature_activated', |
||
| 135 | 'display_text' => get_plugin_lang('SignatureActivated', 'ExerciseSignaturePlugin'), |
||
| 136 | 'default_value' => null, |
||
| 137 | 'field_order' => null, |
||
| 138 | 'visible_to_self' => 1, |
||
| 139 | 'changeable' => 1, |
||
| 140 | 'filter' => null, |
||
| 141 | ] |
||
| 142 | ); |
||
| 143 | } |
||
| 144 | |||
| 145 | $extraFieldHandler = $extraField->get_handler_field_info_by_field_variable('signature_mandatory'); |
||
| 146 | $exists = $extraFieldHandler !== false; |
||
| 147 | |||
| 148 | if (!$exists) { |
||
| 149 | $extraField->save( |
||
| 150 | [ |
||
| 151 | 'field_type' => 13, // checkbox yes/no |
||
| 152 | 'variable' => 'signature_mandatory', |
||
| 153 | 'display_text' => get_plugin_lang('SignatureMandatory', 'ExerciseSignaturePlugin'), |
||
| 154 | 'default_value' => null, |
||
| 155 | 'field_order' => null, |
||
| 156 | 'visible_to_self' => 1, |
||
| 157 | 'changeable' => 1, |
||
| 158 | 'filter' => null, |
||
| 159 | ] |
||
| 160 | ); |
||
| 161 | } |
||
| 162 | |||
| 163 | $extraField = new ExtraField('track_exercise'); |
||
| 164 | $extraFieldHandler = $extraField->get_handler_field_info_by_field_variable('signature'); |
||
| 165 | $exists = $extraFieldHandler !== false; |
||
| 166 | |||
| 167 | if (!$exists) { |
||
| 168 | $extraField->save( |
||
| 169 | [ |
||
| 170 | 'field_type' => 2, // textarea |
||
| 171 | 'variable' => 'signature', |
||
| 172 | 'display_text' => get_plugin_lang('Signature', 'ExerciseSignaturePlugin'), |
||
| 173 | 'default_value' => null, |
||
| 174 | 'field_order' => null, |
||
| 175 | 'visible_to_self' => 1, |
||
| 176 | 'changeable' => 1, |
||
| 177 | 'filter' => null, |
||
| 178 | ] |
||
| 179 | ); |
||
| 180 | } |
||
| 181 | |||
| 182 | $table = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
||
| 183 | $sql = "ALTER TABLE $table MODIFY COLUMN value LONGTEXT null;"; |
||
| 184 | Database::query($sql); |
||
| 185 | } |
||
| 207 |