Conditions | 1 |
Paths | 1 |
Total Lines | 61 |
Code Lines | 12 |
Lines | 0 |
Ratio | 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 |
||
94 | function showForm() |
||
95 | { |
||
96 | ?> |
||
97 | <script> |
||
98 | /** |
||
99 | * Show option fields corresponding to attachment type |
||
100 | * |
||
101 | * @param integer migrationType to show options for |
||
102 | * |
||
103 | * @return void |
||
104 | */ |
||
105 | function showOptions(migrationType) |
||
106 | { |
||
107 | var html = '' |
||
108 | |||
109 | switch(migrationType*1) { |
||
110 | case <?php echo PMF_Attachment_Migration::MIGRATION_TYPE1 ?>: |
||
111 | // nothing to do yet |
||
112 | break; |
||
113 | |||
114 | case <?php echo PMF_Attachment_Migration::MIGRATION_TYPE2 ?>: |
||
115 | /* case <?php echo PMF_Attachment_Migration::MIGRATION_TYPE3 ?>: |
||
116 | case <?php echo PMF_Attachment_Migration::MIGRATION_TYPE4 ?>:*/ |
||
117 | html = 'Default Key: <input name="defaultKey" maxlength="256">' |
||
118 | break; |
||
119 | } |
||
120 | |||
121 | document.getElementById('optionFields').innerHTML = html |
||
122 | } |
||
123 | </script> |
||
124 | <form method="post"> |
||
125 | <table> |
||
126 | <tr> |
||
127 | <td> |
||
128 | <select id="migrationType" name="migrationType" |
||
129 | onchange="showOptions(this.options[this.selectedIndex].value)"> |
||
130 | <option value="<?php echo PMF_Attachment_Migration::MIGRATION_TYPE1 ?>"> |
||
131 | 2.5.x ==> 2.6+ files without encryption |
||
132 | </option> |
||
133 | <option value="<?php echo PMF_Attachment_Migration::MIGRATION_TYPE2 ?>"> |
||
134 | 2.5.x ==> 2.6+ files with encryption |
||
135 | </option> |
||
136 | <!-- <option value="<?php echo PMF_Attachment_Migration::MIGRATION_TYPE3 ?>"> |
||
137 | 2.6+ default encrypted files ==> unencrypted files |
||
138 | </option> |
||
139 | <option value="<?php echo PMF_Attachment_Migration::MIGRATION_TYPE4 ?>"> |
||
140 | 2.6+ unencrypted files ==> default encrypted files |
||
141 | </option>--> |
||
142 | </select> |
||
143 | </td> |
||
144 | </tr> |
||
145 | <tr> |
||
146 | <td id="optionFields"> |
||
147 | |||
148 | </td> |
||
149 | </tr> |
||
150 | <tr><td><input type="submit"></td></tr> |
||
151 | </table> |
||
152 | </form> |
||
153 | <?php |
||
154 | } |
||
155 | |||
158 | </html> |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.