| Conditions | 1 |
| Paths | 1 |
| Total Lines | 74 |
| Code Lines | 62 |
| 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 |
||
| 146 | public function testCustomSettingsMigration() |
||
| 147 | { |
||
| 148 | $service = $this->getService(); |
||
| 149 | $service->setQuiet(true); |
||
| 150 | $service->run(); |
||
| 151 | |||
| 152 | $group1 = $this->objFromFixture('Group', 'group1'); |
||
| 153 | $form = $this->objFromFixture('UserDefinedForm', 'form-with-settings'); |
||
| 154 | $folder = $this->objFromFixture('Folder', 'folder1'); |
||
| 155 | |||
| 156 | $this->assertDOSEquals(array( |
||
| 157 | array( |
||
| 158 | 'ClassName' => 'EditableTextField', |
||
| 159 | 'Title' => 'Text with rule', |
||
| 160 | 'MinLength' => 20, |
||
| 161 | 'MaxLength' => 100, |
||
| 162 | 'Rows' => 4, |
||
| 163 | 'ExtraClass' => 'special class', |
||
| 164 | 'RightTitle' => 'My Field', |
||
| 165 | 'ShowOnLoad' => true, |
||
| 166 | 'Default' => 'Enter your text here', |
||
| 167 | ), |
||
| 168 | array( |
||
| 169 | 'ClassName' => 'EditableNumericField', |
||
| 170 | 'Title' => 'Numeric 1', |
||
| 171 | 'RightTitle' => 'Number of %', |
||
| 172 | 'Default' => 1, |
||
| 173 | 'MinValue' => 1, |
||
| 174 | 'MaxValue' => 100, |
||
| 175 | 'ShowOnLoad' => true, |
||
| 176 | ), |
||
| 177 | array( |
||
| 178 | 'ClassName' => 'EditableMemberListField', |
||
| 179 | 'Title' => 'Members 1', |
||
| 180 | 'RightTitle' => 'Select group', |
||
| 181 | 'GroupID' => $group1->ID, |
||
| 182 | 'ShowOnLoad' => false, |
||
| 183 | ), |
||
| 184 | array( |
||
| 185 | 'ClassName' => 'EditableLiteralField', |
||
| 186 | 'Title' => 'Literal 1', |
||
| 187 | 'HideFromReports' => true, |
||
| 188 | 'RightTitle' => 'Literal', |
||
| 189 | 'Content' => '<p>Content</p>', |
||
| 190 | 'ShowOnLoad' => true, |
||
| 191 | ), |
||
| 192 | array( |
||
| 193 | 'ClassName' => 'EditableFormHeading', |
||
| 194 | 'Title' => 'Heading 1', |
||
| 195 | 'RightTitle' => 'Right', |
||
| 196 | 'Level' => 3, |
||
| 197 | 'HideFromReports' => true, |
||
| 198 | 'ShowOnLoad' => false, |
||
| 199 | ), |
||
| 200 | array( |
||
| 201 | 'ClassName' => 'EditableFileField', |
||
| 202 | 'Title' => 'File 1', |
||
| 203 | 'RightTitle' => 'File field', |
||
| 204 | 'FolderID' => $folder->ID, |
||
| 205 | ), |
||
| 206 | array( |
||
| 207 | 'ClassName' => 'EditableDateField', |
||
| 208 | 'Title' => 'Date 1', |
||
| 209 | 'RightTitle' => 'Date field', |
||
| 210 | 'DefaultToToday' => true, |
||
| 211 | ), |
||
| 212 | array( |
||
| 213 | 'ClassName' => 'EditableCheckbox', |
||
| 214 | 'Title' => 'Checkbox 1', |
||
| 215 | 'CheckedDefault' => true, |
||
| 216 | 'RightTitle' => 'Check this', |
||
| 217 | ), |
||
| 218 | ), $form->Fields()); |
||
| 219 | } |
||
| 220 | } |
||
| 221 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.