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